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