Skip to content

Commit

Permalink
fix: bug with force pushed commits
Browse files Browse the repository at this point in the history
  • Loading branch information
jackton1 committed Sep 25, 2022
1 parent d82ceda commit 8281b8a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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_<VARIABLE_NAME> 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 }}
Expand Down
7 changes: 5 additions & 2 deletions diff-sha.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 8281b8a

Please sign in to comment.