Add required permissions to the workflow_run example - #45612
Merged
Conversation
1 task
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:
Closes: #45520
The
workflow_run"Use the data" example downloads an artifact from the triggering run and then posts a comment withgithub.rest.issues.createComment, and it declares nopermissions:key. Downloading an artifact is documented as needingActions: read, and creating an issue comment asIssues: writeorPull requests: write. The restricted repository default grants read access tocontentsandpackagesonly, and the workflow permissions reference says the effective token starts from that default and changes only through apermissions:key. So a reader who copies the example into a repository on the restricted default gets a workflow that can do neither. On a permissive default it works. That is why the gap is easy to miss.The surrounding section is about handling a potentially untrusted triggering workflow, and the example already carries a security comment about not extracting into the workspace directory. That makes it the example a reader is most likely to copy verbatim and least likely to widen by hand.
What's being changed (if available, include any code snippets, screenshots, or gifs):
A job-level
permissions:block on thedownloadjob:pull-requests: writeis the documented alternative toissues: writehere, not a third permission. Nothing else in the example changes.Check off the following:
I am not GitHub staff, so I left the SME box for a maintainer. The reasoning, the pages I read for the two requirements and the three things that would make the report wrong are in #45520.