From b32c6f15ec31590d7c157cf9ad1aa3ac79871fa9 Mon Sep 17 00:00:00 2001 From: Philip Korsholm Date: Wed, 20 Oct 2021 16:12:44 +0200 Subject: [PATCH] rename script --- .github/workflows/action.yml | 2 +- ...-files-circleci.sh => assert-changed-files-actions.sh} | 8 ++++++-- scripts/assert-changed-files.sh | 8 ++------ 3 files changed, 9 insertions(+), 9 deletions(-) rename scripts/{assert-changed-files-circleci.sh => assert-changed-files-actions.sh} (64%) mode change 100755 => 100644 mode change 100644 => 100755 scripts/assert-changed-files.sh diff --git a/.github/workflows/action.yml b/.github/workflows/action.yml index 1149fae5f5..2c3063d248 100644 --- a/.github/workflows/action.yml +++ b/.github/workflows/action.yml @@ -17,7 +17,7 @@ jobs: cache: "yarn" - name: Assert changed - run: ./scripts/assert-changed-files.sh "packages" + run: ./scripts/assert-changed-files-actions.sh "packages" - name: Bootstrap packages uses: ./.github/actions/cache-bootstrap diff --git a/scripts/assert-changed-files-circleci.sh b/scripts/assert-changed-files-actions.sh old mode 100755 new mode 100644 similarity index 64% rename from scripts/assert-changed-files-circleci.sh rename to scripts/assert-changed-files-actions.sh index 1efc93e933..2a45a8f650 --- a/scripts/assert-changed-files-circleci.sh +++ b/scripts/assert-changed-files-actions.sh @@ -21,11 +21,15 @@ if [ "$IS_CI" = true ]; then git config --local --unset url."https://github.com/".insteadOf fi -FILES_COUNT="$(git diff-tree --no-commit-id --name-only -r "$CIRCLE_BRANCH" origin/master | grep -E "$GREP_PATTERN" -c)" +# Make sure that we are diffing towards the right branch, in github actions this is different +# depending on whether or not we are creating a pull request or not. +[ ! -z ${GITHUB_BASE_REF} ] && HAS_BASE=true || HAS_BASE=false +[ HAS_BASE = true ] && COMPARE="${GITHUB_BASE_REF#refs/heads/}" || COMPARE="develop" +FILES_COUNT="$(git diff-tree --no-commit-id --name-only -r origin/"$COMPARE" | grep -E "$GREP_PATTERN" -c)" if [ "$IS_CI" = true ]; then # reset to previous state - git reset --hard $CIRCLE_SHA1 + git reset --hard $GITHUB_SHA fi if [ "$FILES_COUNT" -eq 0 ]; then diff --git a/scripts/assert-changed-files.sh b/scripts/assert-changed-files.sh old mode 100644 new mode 100755 index 2a45a8f650..1efc93e933 --- a/scripts/assert-changed-files.sh +++ b/scripts/assert-changed-files.sh @@ -21,15 +21,11 @@ if [ "$IS_CI" = true ]; then git config --local --unset url."https://github.com/".insteadOf fi -# Make sure that we are diffing towards the right branch, in github actions this is different -# depending on whether or not we are creating a pull request or not. -[ ! -z ${GITHUB_BASE_REF} ] && HAS_BASE=true || HAS_BASE=false -[ HAS_BASE = true ] && COMPARE="${GITHUB_BASE_REF#refs/heads/}" || COMPARE="develop" -FILES_COUNT="$(git diff-tree --no-commit-id --name-only -r origin/"$COMPARE" | grep -E "$GREP_PATTERN" -c)" +FILES_COUNT="$(git diff-tree --no-commit-id --name-only -r "$CIRCLE_BRANCH" origin/master | grep -E "$GREP_PATTERN" -c)" if [ "$IS_CI" = true ]; then # reset to previous state - git reset --hard $GITHUB_SHA + git reset --hard $CIRCLE_SHA1 fi if [ "$FILES_COUNT" -eq 0 ]; then