Skip to content
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

Creating cross-repo Pull Request #2538

Closed
parteekcoder opened this issue May 30, 2023 · 6 comments
Closed

Creating cross-repo Pull Request #2538

parteekcoder opened this issue May 30, 2023 · 6 comments

Comments

@parteekcoder
Copy link

parteekcoder commented May 30, 2023

I have 2 repositories

repo1 = Organization/project
repo2 = user/project  (it is forked of repo1)

Can I create a Pull Request from repo2 to repo1 using a Fine-Grained token with the required access of repo2 using PyGithub, If yes can you please help me to do that

@parteekcoder
Copy link
Author

parteekcoder commented May 30, 2023

Here is what I am doing:

g = Github("token")  # (token of repo2)
repo1 = g.get_repo("organization/project")
repo2 = g.get_repo("user/project")
repo1.create_pull(title="PR_TITLE", body="PR_BODY", base="main",head="user/project:main")

I am getting this error

github.GithubException.GithubException: 403 {"message": "Resource not accessible by personal access token", "documentation_url": "https://docs.github.com/rest/reference/pulls#create-a-pull-request"}

@EnricoMi
Copy link
Collaborator

Have you tried

repo1.create_pull(title="PR_TITLE", body="PR_BODY", base="main",head="user:main")

Maybe it is a permission issue. Not sure which fine grained permissions are needed to create a pull request on a public repo.

@EnricoMi EnricoMi changed the title Creating Pull Requests Creating cross-repo Pull Request Jun 20, 2023
@parteekcoder
Copy link
Author

Yeah Thanks @EnricoMi , i figured out another way to do that.

@EnricoMi
Copy link
Collaborator

Would you like to share your findings?

@parteekcoder
Copy link
Author

yeah , I used github cli

gh pr create --repo "project" --base "user:main" --head "main"

Make sure before running this command you have access to create PR to upstream repo

@EnricoMi
Copy link
Collaborator

From looking at the Github REST API docs, this should also work with PyGithub.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants