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

Switch to pull_request_target in labeler workflow #4101

Merged
merged 4 commits into from
Oct 7, 2024

Conversation

mastercactapus
Copy link
Member

@mastercactapus mastercactapus commented Oct 7, 2024

This pull request switches the labeler workflow to use pull_request_target instead of pull_request as the event trigger.

The difference is that pull_request_target defaults to running checkout commands from the BASE branch, instead of the merge commit.

The reason for this is so that outside contributors/forked repos can't open PRs that execute their own code.


To analyze changes, we now check out the codebase twice: once is the base branch (e.g., usually master) and runs the labeler script from there only. It runs git diff from the merge checkout location, so the numbers are from there.

This allows external PRs to have the labeler run and apply labels, but only by executing code from a branch already in the repo (i.e., created by those with write-access) rather than the incoming code.

Lastly, this means that changes to the labeler script will only take effect AFTER they have been merged, so to validate labeler updates in the future, a separate PR will need to be opened against the branch in question.

For validation of THIS PR:

We cd into the merge checkout, and then execute the script from the ../base dir


Output:

m17ch
m17ch previously approved these changes Oct 7, 2024
@mastercactapus mastercactapus merged commit 9118acf into master Oct 7, 2024
6 checks passed
@mastercactapus mastercactapus deleted the label-from-target branch October 7, 2024 18:56
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 this pull request may close these issues.

3 participants