-
-
Notifications
You must be signed in to change notification settings - Fork 412
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PR creation failing from Org fork with - {"resource":"PullRequest","field":"head","code":"invalid"} #2043
Comments
@FoSix Thankyou for your very detailed report of the issue. I notice that it has created the pull request branch successfully, but the PR creation failed. So it doesn't appear to be an issue related to token permissions. My guess is that the action is struggling with the fact that the parent repo and fork are in the same org. That is not really normal since forks are usually made into a different org or user account. I'll investigate to see if there is something I can do to handle this case. |
I did some testing with with GH's REST API and octokit.rest.pulls.create({
owner: "fosixorg",
repo: "base",
head: "fosixorg:create-pull-request/patch",
head_repo: "fosixorg/fork",
base: "main",
title: "script base PR",
body: "created with GH script",
}) Proven to work here. What does the trick is the I'm not a JS developer so (unfortunately) I cannot propose a PR with code changes... |
@FoSix Great work testing and finding that parameter! I've created a branch with the change to add You can test the PR version of the action like this: - uses: peter-evans/create-pull-request@head-repo If it works fine I'll merge it in and create a new release. |
Sure! UPDATE: @peter-evans it looks great, it seems to work, for both forks (org and personal) |
Thank you for testing! ❤️ Released as |
I know it's similar issues were already posted, I've read them, didn't find a solution, so bare with me for a sec 😄
TL;DR
The problem goes down to this error:
being thrown when creating a PR from a fork which belongs to an organisation, the same organisation to which the base repo belongs to.
SETUP
We have to repos under an organisation, both public, let's call them:
base
- a repo to which we would like introduce changes, we have read only access, hence changes have to be merged by a PR from a forkCI
- hosting a workflow, triggered onpull_request
WORKFLOW
The workflow is simple, when a PR is created in the CI repo:
create-pull-request
action to create a PR using a fork.When the fork is a personal fork (not under organisation) everything works. The problem pops up when the fork is inside the same organisation as the base repo.
PAT used for this is the classic type with
public_repo
access. I did try with all possible accesses but it does not seem to be an access problem. The account for which PAT was generated is a regular organisation member with owner access to CI repo and an owner of both forks.Below you can find links to test repos I used to reproduce the problem:
I did already spent a lot of time on this, so any help (even pointing out what I'm doing wrong) would be highly appreciated.
The text was updated successfully, but these errors were encountered: