From 7d35afd30d497294c95630de88e05e0d94ed5e16 Mon Sep 17 00:00:00 2001 From: simeng-li Date: Mon, 8 Jan 2024 18:31:46 +0800 Subject: [PATCH] fix: fix the db alter detect ci script (#5210) fix the db alter detect ci script --- .../alteration-compatibility-integration-test.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/alteration-compatibility-integration-test.yml b/.github/workflows/alteration-compatibility-integration-test.yml index 3a86ece2f..96cd0493c 100644 --- a/.github/workflows/alteration-compatibility-integration-test.yml +++ b/.github/workflows/alteration-compatibility-integration-test.yml @@ -23,11 +23,18 @@ jobs: fetch-depth: 0 # compare the current codebase with HEAD and check if there are any changes under the alterations folder + # if the event is a pull request, we need to compare the merge base with HEAD, otherwise we compare the current commit with the previous commit - name: Check for alteration changes id: changes-detection run: | - MERGE_BASE=$(git merge-base origin/${{github.base_ref}} HEAD) - CHANGE_FILES=$(git diff --name-only $MERGE_BASE | grep 'packages/schemas/alterations/' || true) + if [[ "${{ github.event_name }}" == "pull_request" ]]; then + BASE=$(git merge-base origin/${{github.base_ref}} HEAD) + else + BASE=${{ github.event.before }} + fi + + CHANGE_FILES=$(git diff --name-only $BASE | grep 'packages/schemas/alterations/' || true) + if [ -n "$CHANGE_FILES" ]; then echo "$CHANGE_FILES" echo "::set-output name=has-alteration-changes::true"