Add explicit permissions blocks to caller workflow templates#136
Merged
Conversation
Each template now declares the minimum GITHUB_TOKEN ceiling its caller workflow needs, rather than relying on the org/repo default_workflow_permissions setting. This means each workflow's effective privileges live in the YAML (visible in code review) rather than in a settings page, and any future change to the org or repo Actions default can only narrow (never widen) what these workflows can do. Per-workflow permissions: - Tests, FormatCheck, CheckCompatBounds: contents: read - VersionCheck: contents: read, pull-requests: read - IntegrationTest: actions: read, contents: read - Documentation: contents: write (gh-pages deploy) - TagBot: contents: write, issues: read Existing already-permissioned workflows (CompatHelper, FormatPullRequest, IntegrationTestRequest, Registrator) were not changed. FormatCheckComment was normalized from a job-level block to a workflow-level block so all caller files follow the same shape. Verified end-to-end on ITensor/SparseArraysBase.jl with that repo's per-repo default_workflow_permissions flipped to `read` and can_approve_pull_request_reviews flipped to `false` to mirror the planned org-default end state. All workflows pass under the read-only ceiling with these blocks in place.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #136 +/- ##
=======================================
Coverage 87.34% 87.34%
=======================================
Files 1 1
Lines 158 158
=======================================
Hits 138 138
Misses 20 20
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Summary
Adds explicit
permissions:blocks to each of the workflow templates that callers consume. Previously most templates declared nopermissions:block at all, so the resulting per-repo workflow files inherited theirGITHUB_TOKENceiling from whatever the consuming repo's Actions default happened to be (currentlydefault_workflow_permissions: writeorg-wide).After this change, every workflow declares its own minimum ceiling in the YAML. Any future change to the org or per-repo Actions default can only narrow (never widen) what these workflows can do — the security posture lives in code review (the YAML diff) rather than in admin clicks.
Per-workflow permissions
The minimum each workflow actually needs:
contents: read(checkout-only).contents: read,pull-requests: read(reads the PR's changed-file list to decide whether a version bump is required).actions: read,contents: read(the gate job inspects matrix-leg results via the Actions API).contents: write(gh-pages deploy).contents: write,issues: read(creates the release tag, reads PR/issue refs for release notes).Already-permissioned templates (
CompatHelper,FormatPullRequest,IntegrationTestRequest,Registrator) were left unchanged.FormatCheckCommentwas normalized from a job-level block to a workflow-level block so all caller files follow the same shape.How it was verified
End-to-end on
ITensor/SparseArraysBase.jl(PR #176) with that repo's per-repo Actions setting temporarily flipped todefault_workflow_permissions: readandcan_approve_pull_request_reviews: false— the same end state planned for the org defaults later. Without these blocks, three workflows fail to start with errors like "The nested job 'tests' is requesting 'contents: write', but is only allowed 'contents: read'". With the blocks in place, all workflows pass under the read-only ceiling.Impact for downstream consumers
No behavior change. Each workflow continues to do exactly what it did before. After this lands, packages that re-render their workflows from the templates pick up the new permissions blocks;
MassApplyPatchwill propagate the same shape across the rest of the ecosystem in a follow-up sweep.