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

Cannot use event pull_request on OSS repositories, GitHub token is read-only #25

Closed
matks opened this issue Sep 15, 2021 · 3 comments · Fixed by #26
Closed

Cannot use event pull_request on OSS repositories, GitHub token is read-only #25

matks opened this issue Sep 15, 2021 · 3 comments · Fixed by #26

Comments

@matks
Copy link
Contributor

matks commented Sep 15, 2021

Hello, this GitHub Action works well if you are using the same repository for all contributors.

But if you use it with a OSS repository that require contributors to use their fork, it does not work because the GitHub API token has read-only permissions only, so it cannot add labels to a PR. See reference https://github.community/t/github-actions-are-severely-limited-on-prs/18179

The solution suggested by GitHub is to rely on GA event pull_request_target

In order to solve this, we’ve added a new pull_request_target event, which behaves in an almost identical way to the pull_request event with the same set of filters and payload. However, instead of running against the workflow and code from the merge commit, the event runs against the workflow and code from the base of the pull request. This means the workflow is running from a trusted source and is given access to a read/write token as well as secrets enabling the maintainer to safely comment on or label a pull request. This event can be used in combination with the private repository settings as well.

@matks
Copy link
Contributor Author

matks commented Sep 15, 2021

I submit a Pull Request #26

@ffittschen ffittschen linked a pull request Sep 15, 2021 that will close this issue
@ffittschen
Copy link
Owner

Thanks for the heads up and the PR 🙂 I actually did not use it with a fork workflow so far so I didn't notice this before

@matks
Copy link
Contributor Author

matks commented Sep 15, 2021

We started using it on https://github.com/prestashop/docs 😉 so we quickly noticed

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

Successfully merging a pull request may close this issue.

2 participants