ci: stop labelling fork pull requests in the PR title check - #207
Merged
Merged
Conversation
A pull request from a fork runs with a read-only token, so the label step failed with "Resource not accessible by integration" and turned the check red even for a valid title. Labels are now only added for pull requests opened from a branch of this repository. Also declares least-privilege permissions and pins the action to a commit SHA.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
validate-pr-titlefails on every pull request opened from a fork (#200, #201, #202, #206) withResource not accessible by integration, even when the title is valid. The action validates the title, then adds type and scope labels; apull_requestrun triggered from a fork only gets a read-onlyGITHUB_TOKEN, so the label call is refused and the job fails.What
add_labelandadd_scope_labelare enabled only when the head repository is this repository. Fork pull requests are still validated, just not labelled. The action compares the input to the stringfalseand skips the label calls.contents: readat the workflow level,pull-requests: writeonly on the job (needed for the labels).1.5.2instead of the mutable tag.pull_request_targetwould restore labels on fork PRs, but it hands a write token to runs triggered by external contributors; not worth it for labels.Check
This pull request comes from a fork and runs the modified workflow:
validate-pr-titleshould be green here.