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

support pull_request_target event #296

Open
KhudaDad414 opened this issue Apr 6, 2022 · 3 comments
Open

support pull_request_target event #296

KhudaDad414 opened this issue Apr 6, 2022 · 3 comments

Comments

@KhudaDad414
Copy link

KhudaDad414 commented Apr 6, 2022

Context

We were using this action to update branches and it worked fine for push event. Now we are trying to add the capability for contributors to update their branch from PRs.

Problem

Since we are using forks for contributions and the pull_request event causes the workflow to run on the fork, and forks don't have access to the secrets, hence, this error will show up: https://github.com/asyncapi/glee/runs/5838503289?check_suite_focus=true

Possible solution

adding support for pull_request_target may be the solution here.

Related to #212

@kevinrobayna
Copy link

I don’t believe this is possible from what I know from the GH API. In order to do this the action would need to know about the forks and have permission on the fork itself.

After the above it would somehow trigger the update from the fork 😅

@ReenigneArcher
Copy link

ReenigneArcher commented Dec 12, 2022

@KhudaDad414 did you ever find a solution for this?

I'm also trying to update branches of PRs from forks (if a contributor has "allow edits by maintainers" and also checks a box in my PR template).

I'm using pull_request_target along with a personal access token. I gave the PAT just about every permission feasible, but didn't seem to make any difference.

Error: Could not update pull request #34 due to an authorisation error. This is probably because this pull request is from a fork and the current token does not have write access to the forked repository. Error was: Must have admin rights to Repository.

The user who own's the PAT is an owner of my repo...

I can also update the PR from this button, so seems like I do have proper permissions.
image

Edit:
I would think if "allow edits and access to secrets by maintainers" is checked, it would be enough of a permission... assuming the token is from a user who is a maintainer of the repo.

image

@ephys
Copy link

ephys commented Apr 12, 2024

I think I've finally found the solution to this problem. To bypass github's API limitations, I did the update via git instead of the API: https://github.com/sequelize/pr-auto-update-and-handle-conflicts/blob/74929c430b8843e691e7b83d229d8d13d78d89e3/src/action.ts#L331-L398

Feel free to copy the solution for this project

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

4 participants