Failing to commit to fork in pull requests
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 8.9k
- Forks
- 2.8k
- PR merge metrics
- No merged PRs in 30d
Description
Trying 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?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names no source files or tests. Start by reproducing the checkout and fetch failures for pull requests from forks, comparing the default checkout with the github.head_ref configuration; done means identifying a supported configuration or confirming the limitation for committing to fork branches.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- git, github-actions
- Domain
- ci-cd, devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100