Failing to commit to fork in pull requests
See original GitHub issueTrying to file an issue, because I feel like there must be a solution, but I’ve been unable to find it so far.
I want to create an action that runs on specific pull requests (based on the label), and commit changes (i.e. fixes) on the same branch.
I tried with the default settings, and when I try to commit, I get this error
fatal: You are not currently on a branch.
To push the history leading to the current (detached HEAD)
state now, use
git push origin HEAD:<name-of-remote-branch>
Error: Process completed with exit code 128.
After searching in existing issues, I found the suggestion to clone with ref: ${{ github.head_ref }}
. And that works perfectly, but only if the pull request is coming from the same repository. If I try to run it on a pull request coming from a fork, I get this error instead, still in the cloning phase (Fetching the repository
):
/usr/bin/git -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 origin +refs/heads/test_pr_outside*:refs/remotes/origin/test_pr_outside* +refs/tags/test_pr_outside*:refs/tags/test_pr_outside*
The process '/usr/bin/git' failed with exit code 1
Waiting 11 seconds before trying again
/usr/bin/git -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 origin +refs/heads/test_pr_outside*:refs/remotes/origin/test_pr_outside* +refs/tags/test_pr_outside*:refs/tags/test_pr_outside*
The process '/usr/bin/git' failed with exit code 1
Waiting 13 seconds before trying again
/usr/bin/git -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 origin +refs/heads/test_pr_outside*:refs/remotes/origin/test_pr_outside* +refs/tags/test_pr_outside*:refs/tags/test_pr_outside*
Error: The process '/usr/bin/git' failed with exit code 1
If I try adding fetch-depth: 0
, the error changes to
Determining the checkout info
/usr/bin/git branch --list --remote origin/test_pr_outside
/usr/bin/git tag --list test_pr_outside
Error: A branch or tag with the name 'test_pr_outside' could not be found
test_pr_outside
it’s indeed the name of the branch on the fork, but it’s clearly not available in origin
.
Any suggestion?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:10
- Comments:5
Top GitHub Comments
I think I’ve figured out how to ensure that cloning works even from forks.
Working:
Not working:
Even if “Allow changes by maintainers” is enabled (i.e. actions are not enabled on the fork), I get a
fatal: unable to access 'fork_repo': The requested URL returned error: 403
. Do I need an SSH_KEY to solve that, because the action token is not sufficient?EDIT: never mind, tried with ssh-key and getting exactly the same error 😔
Hi this only seems to work for public repos. Private repos don’t seem to work.