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

Enforce PR labels: use pull_request_target trigger to work with PRs coming from forks #52981

Merged
merged 1 commit into from
Jul 26, 2023

Conversation

priethor
Copy link
Contributor

Follow-up to #52980 and #52980

What?

The action that enforces PR labels set in #52980 doesn't work properly with PRs coming from forks. This PR changes the action trigger to fix this issue and work with all PRs.

Why?

When using the pull_requestevent, ${{ secrets.GITHUB_TOKEN }} is not given write permissions.

How?

By using the pull_request_target event instead:

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.

Testing Instructions

Once merged, change a label or update a PR that is coming from a fork and check the Enforce PR labels action is passing.

@priethor priethor added the [Type] Project Management Meta-issues related to project management of Gutenberg label Jul 26, 2023
@priethor priethor requested a review from ockham July 26, 2023 14:52
@priethor priethor self-assigned this Jul 26, 2023
@github-actions
Copy link

Flaky tests detected in 85d5f73.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5670328814
📝 Reported issues:

@priethor priethor merged commit 7eddee3 into trunk Jul 26, 2023
@priethor priethor deleted the try/enforce-prs-use-pull_request_target branch July 26, 2023 16:10
@github-actions github-actions bot added this to the Gutenberg 16.4 milestone Jul 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Project Management Meta-issues related to project management of Gutenberg
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant