Remove excess permissions from pages workflows #2597
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.
The various pages workflows all set a top level permissions block which was unfortunate.
With the exception of the static workflow, each workflow had two jobs, one that only needed
contents: read
and one that didn't even needcontents: read
.I'm splitting the permissions block for each of those workflows such that the build phase only gets
contents: read
and the publish phase getspages: write
andid-token: write
(but not evencontents: read
as it doesn't need it).For the static workflow, I'm moving the permissions into the job for consistency and also to make it easier to compose this job into some bigger workflow.
I discovered the overly generous permissions when I was applying the pages/jekyll-gh-pages.yml into a workflow I have...
Please note that at this time we are only accepting new starter workflows for Code Scanning. Updates to existing starter workflows are fine.
Tasks
For all workflows, the workflow:
.yml
file with the language or platform as its filename, in lower, kebab-cased format (for example,docker-image.yml
). Special characters should be removed or replaced with words as appropriate (for example, "dotnet" instead of ".NET").GITHUB_TOKEN
so that the workflow runs successfully.For CI workflows, the workflow:
ci
directory.ci/properties/*.properties.json
file (for example,ci/properties/docker-publish.properties.json
).push
tobranches: [ $default-branch ]
andpull_request
tobranches: [ $default-branch ]
.release
withtypes: [ created ]
.docker-publish.yml
).Some general notes:
actions
organization, or