3
0
Fork 0
mirror of https://github.com/tj-actions/changed-files synced 2025-03-05 21:06:25 +00:00

fix: bug with force pushed commits

This commit is contained in:
Tonye Jack 2022-09-25 09:19:22 -06:00
parent d82ceda8a1
commit 8281b8ad57
2 changed files with 6 additions and 2 deletions

View file

@ -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 }}

View file

@ -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