diff --git a/README.md b/README.md index 2ea2f31277b..1c88b6f6505 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ ## changed-files -Retrieve all changed files and directories relative to the target branch (`pull_request*` based events) or the last remote commit (`push` based event) returning the **absolute path** to all changed files and directories from root of the project. +Retrieve all changed files and directories relative to the target branch (`pull_request*` based events) or the last remote commit (`push` based event) returning the **absolute path** to all changed files and directories from the project root. ## Features diff --git a/action.yml b/action.yml index a30d008bd2e..47761ad6fe2 100644 --- a/action.yml +++ b/action.yml @@ -154,8 +154,13 @@ runs: # "Set base sha..." if [[ -n "${{ inputs.base_sha }}" ]]; then echo "::set-output name=base_sha::${{ inputs.base_sha }}" - elif [[ "${{ inputs.since_last_remote_commit }}" == "true" && "${{ github.event.before }}" != "0000000000000000000000000000000000000000" ]]; then - echo "::set-output name=base_sha::${{ github.event.before }}" + elif [[ "${{ inputs.since_last_remote_commit }}" == "true" && "${{ github.event.forced }}" == "true" && "${{ github.event.before }}" != "0000000000000000000000000000000000000000" ]]; then + LAST_REMOTE_COMMIT=$(git rev-parse $(git branch -r --sort=-committerdate | head -1)) + if [[ "${{ inputs.sha }}" != "$LAST_REMOTE_COMMIT" ]]; then + echo "::set-output name=base_sha::$LAST_REMOTE_COMMIT" + fi + elif [[ "${{ inputs.since_last_remote_commit }}" == "true" && "${{ github.event.forced }}" != "true" && "${{ github.event.before }}" != "0000000000000000000000000000000000000000" ]]; then + echo "::set-output name=base_sha::${{ github.event.before }}" fi id: base-sha shell: bash