Skip to content

Failing to commit to fork in pull requests #455

@flodolo

Description

@flodolo

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions