Closed VaibhavSaini19 closed 3 years ago
Thanks for reporting!
I've now invested like +2 hours investigating this.
In short: I have no idea why pull_request_target
doesn't work as advertised. However, I could fix it by just using push
in th workflow.
Through a secondary Account I've created a fork of my test repository and made some changes: https://github.com/wnxtrash/git-auto-commit-action-demo-app/tree/fork/patch-2
The resulting PR never successfully runs the git-auto-commit Action with the pull_request
or pull_request_target
triggers:
https://github.com/stefanzweifel/git-auto-commit-action-demo-app/pull/21
The Action isn't even triggered in the fork. Eventhough the pull_request_target
is especially designed to run in an Action in the forked repository
https://github.com/wnxtrash/git-auto-commit-action-demo-app/actions?query=workflow%3A%22Format+PHP%22
In a last attempt I just added the push
-trigger.
This worked and the workflow was run as expected on the fork.
The README already states that running this Action in forks is quite complicated.
As you can see, your contributors have to go through hoops to make this work. For Workflows which runter linters and fixers (like the example above) we recommend running them when a push happens on the master-branch.
I will update the README in 2 ways:
push
-triggerSorry if I vent here. It's not targeted against you. 🙂
It's just very frustrating if something that worked a month ago no longer works as expected.
It also feels to me that the pull_request_target
-trigger is not really that stable. I personally think it's quite complicated to understand, when to use it and especially how to use it.
Adding push
to the trigger events did the job, thank you so much for your time.
And sorry for the inconvenience caused. Even I was frustrated with all these errors. Anyway, thanks again
@VaibhavSaini19 No worries! Thanks for reporting. Only thanks to issues and discussions we can make this Action better :D
@stefanzweifel I see the exact same issue. For some reasons, adding commits after the PR changes are pushed to master is not an option. I need to update the same PR (from the fork) with additional commits.
In short, is there a fix to this issue other than changing trigger to push
?
Note that, I have gone through the section in README on this and have-
pull_request_target
trigger.@HarshitaInfoblox I don't think there is another option. My example project mentioned in https://github.com/stefanzweifel/git-auto-commit-action/issues/117#issuecomment-710822378 only worked after adding a push
listener that wasn't scoped to a branch (https://github.com/stefanzweifel/git-auto-commit-action-demo-app/pull/21/commits/421eb666b88d8a07b0357c42eb2ace50914febaf).
You mention "Run workflows from pull requests". So I assume you're using the Action in private repositories with private forks? I couldn't test the Action in this environment so far. If you find a solution, feel free to update a PR to update the docs.
Version of the Action
v4
Describe the bug The repo uses this action to automatically commit workflow changes back to the repo. But when a PR is made from a branch of a fork (with actions enabled), the actions fails with
I went through this thread which states that this (or similar) issue was fixed in
v2
, but I am still having this issueTo Reproduce Fork the repo, commit changes in a new branch, create a PR
Expected behavior The changes to be successfully committed in the PR branch which can be merged
I think git is unable to find the branch?
Screenshots
Failed workflow: https://github.com/s-katte/React-Code-Pen/pull/27/checks?check_run_id=1267689707
Used Workflow
Additional context We even tried it without the
branch
option, but it still failed