Force Push Unexpected Behavior
I noticed the test would not work as expected when a force push happens, since the pushed commit is checked against itself, hence only the changes in comparison with the previous version of the commit are put into consideration. Although this looks to be the correct behavior, it can cause issues in some scenarios as I expected to detect the existence of the filter in the pushed commit.
Since I believe both behaviors can be beneficial to certain needs, can we have an additional option for this action to let us choose between the two? Or is it currently hackable through the current options?
For everyone stumbling upon this problem (as I did), here is a workaround:
- uses: actions/checkout@v4
with:
fetch-depth: 2 # important, to fetch previous commit
# workaround for https://github.com/dorny/paths-filter/issues/240
- id: previous-sha
run: 'echo "sha=$(git rev-list -n 1 ${{ github.ref }}^)" >> $GITHUB_OUTPUT'
- uses: dorny/paths-filter@v3
id: filter
with:
base: "${{ steps.previous-sha.outputs.sha }}"
filters: |
myfilters: ./**/*
For everyone stumbling upon this problem (as I did), here is a workaround:
- uses: actions/checkout@v4 with: fetch-depth: 2 # important, to fetch previous commit # workaround for https://github.com/dorny/paths-filter/issues/240 - id: previous-sha run: 'echo "sha=$(git rev-list -n 1 ${{ github.ref }}^)" >> $GITHUB_OUTPUT' - uses: dorny/paths-filter@v3 id: filter with: base: "${{ steps.previous-sha.outputs.sha }}" filters: | myfilters: ./**/*
I just had the same issue and this looks reasonable but wouldn't you want to use git fetch origin/main && git rev-parse origin/main instead of ${{ github.ref }} to diff against?