From 8281b8ad57ecacf79e503f7ec2f56335dc770478 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sun, 25 Sep 2022 09:19:22 -0600 Subject: [PATCH 1/3] fix: bug with force pushed commits --- action.yml | 1 + diff-sha.sh | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 47f6744c7fe..f2ff233c49b 100644 --- a/action.yml +++ b/action.yml @@ -190,6 +190,7 @@ runs: GITHUB_WORKSPACE: ${{ github.workspace }} GITHUB_PULL_REQUEST_BASE_SHA: ${{ github.event.pull_request.base.sha }} GITHUB_EVENT_BEFORE: ${{ github.event.before }} + GITHUB_EVENT_FORCED : ${{ github.event.forced }} # INPUT_ is not available in Composite run steps # https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#example-specifying-inputs INPUT_SHA: ${{ steps.sha.outputs.sha }} diff --git a/diff-sha.sh b/diff-sha.sh index c07ae21dd57..73e17e43bbd 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -62,10 +62,13 @@ if [[ -z $GITHUB_BASE_REF ]]; then CURRENT_BRANCH=$TARGET_BRANCH && exit_status=$? || exit_status=$? if [[ -z $INPUT_BASE_SHA ]]; then - PREVIOUS_SHA=$GITHUB_EVENT_BEFORE + PREVIOUS_SHA="" + + if [[ "$GITHUB_EVENT_FORCED" != "true" ]]; then + PREVIOUS_SHA=$GITHUB_EVENT_BEFORE + fi if [[ -z "$PREVIOUS_SHA" || "$PREVIOUS_SHA" == "0000000000000000000000000000000000000000" ]]; then - echo "::debug::First commit detected" PREVIOUS_SHA=$(git rev-parse "$(git branch -r --sort=-committerdate | head -1 | xargs)") fi From 7de6088904f1e9e30d3a6ab6b2d6815161ce5789 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sun, 25 Sep 2022 09:23:05 -0600 Subject: [PATCH 2/3] Updated check --- diff-sha.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/diff-sha.sh b/diff-sha.sh index 73e17e43bbd..36268db4a3c 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -64,7 +64,7 @@ if [[ -z $GITHUB_BASE_REF ]]; then if [[ -z $INPUT_BASE_SHA ]]; then PREVIOUS_SHA="" - if [[ "$GITHUB_EVENT_FORCED" != "true" ]]; then + if [[ "$GITHUB_EVENT_FORCED" == "false" ]]; then PREVIOUS_SHA=$GITHUB_EVENT_BEFORE fi From b50afacfed4e19c43bf5cf0959cf84518c37c36d Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sun, 25 Sep 2022 09:31:57 -0600 Subject: [PATCH 3/3] updated get-base-sha.sh --- action.yml | 1 + get-base-sha.sh | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index f2ff233c49b..9d898b1d787 100644 --- a/action.yml +++ b/action.yml @@ -158,6 +158,7 @@ runs: env: GITHUB_WORKSPACE: ${{ github.workspace }} GITHUB_EVENT_BEFORE: ${{ github.event.before }} + GITHUB_EVENT_FORCED : ${{ github.event.forced }} # INPUT_ is not available in Composite run steps # https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#example-specifying-inputs INPUT_SINCE: ${{ inputs.since }} diff --git a/get-base-sha.sh b/get-base-sha.sh index 3b6efb024c3..77262f622d3 100644 --- a/get-base-sha.sh +++ b/get-base-sha.sh @@ -22,10 +22,13 @@ if [[ -n "$INPUT_SINCE" ]]; then elif [[ -n "$INPUT_BASE_SHA" ]]; then echo "::set-output name=base_sha::$INPUT_BASE_SHA" elif [[ "$INPUT_SINCE_LAST_REMOTE_COMMIT" == "true" ]]; then - LAST_REMOTE_COMMIT="$GITHUB_EVENT_BEFORE" + LAST_REMOTE_COMMIT="" + + if [[ "$GITHUB_EVENT_FORCED" == "false" ]]; then + LAST_REMOTE_COMMIT=$GITHUB_EVENT_BEFORE + fi if [[ -z "$LAST_REMOTE_COMMIT" || "$LAST_REMOTE_COMMIT" == "0000000000000000000000000000000000000000" ]]; then - echo "::debug::First commit detected" LAST_REMOTE_COMMIT=$(git rev-parse "$(git branch -r --sort=-committerdate | head -1 | xargs)") fi if [[ "$INPUT_SHA" == "$LAST_REMOTE_COMMIT" ]]; then