Open ScottPierce opened 1 year ago
I'm having a similar problem. The action works perfectly fine in PRs/branches, but once I perform a merge operation... it fails because of the same problem.
I'm considering doing something similar as to what you have done, although perhaps even more complicated, with some added conditional logic to only perform the checkout when there is a merge operation (what remains to be seen is how I'll make it to define base
conditionally, as it doesn't make sense to obtain PREV_COMMIT_SHA
if I didn't perform a checkout yet).
Another option is to make this to not execute this action on merge, and modify the conditionals that depend on this one to also execute on merge. That would save less time in CI, but I don't expect as many merge operations as commits to PRs.
EDIT: It seems that we can use conditionals in expressions https://github.com/actions/runner/issues/409 , the approximation is a bit brittle ("same" as in POSIX shell, ugh), but better than nothing.
Hi both.
Can't you achieve this with just base: ${{ github.ref }}
? It seems that its working correctly for both open PRs and further pushes to the PR and when I merge the PR to main
. Curious if I'm missing anything.
I have the same problem and I'm curious to know if anyone has a solution before I start spending time on tests
Same issue here where no changes exist when PR is merged into main.
My use case involves a merge commit from a main branch PR to a different branch. I have successfully managed to get it working.
I needed to download the full repo, get the previous commit and use it as a base.
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get previous commit
id: prev-commit
run: |
PREV_COMMIT=$(git rev-list -n 1 HEAD^1)
echo "PREV_COMMIT=$PREV_COMMIT" >> $GITHUB_ENV
- id: filter
uses: dorny/paths-filter@v3
with:
base: ${{ env.PREV_COMMIT }}
Thanks! My solution was to avoid running the action all together on pushes to main (not needed for my use case to begin with) - and instead run it on pull requests only.
I'm trying to detect changes on the main branch when merging a PR into the main branch. I kept on getting
I've solved it by
Surely I'm over complicating this, and there is a simpler way to do this?