Skip to content

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

Merged
priethor merged 1 commit into
trunkfrom
try/enforce-prs-use-pull_request_target
Jul 26, 2023
Merged

Enforce PR labels: use pull_request_target trigger to work with PRs coming from forks#52981
priethor merged 1 commit into
trunkfrom
try/enforce-prs-use-pull_request_target

Conversation

@priethor

Copy link
Copy Markdown
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
Copy Markdown

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