ci: declare per-workflow permissions and move registry creds to environments - #161
Merged
Merged
Conversation
…onments
Prep so the repo-level default GITHUB_TOKEN can be set to read-only.
- Every workflow now declares an explicit `permissions:` block.
create_new_tag.yml is the only one that needs contents: write (it tags
and pushes tags); the rest are contents: read.
- push-to-gh-pkgs.yml grants packages + id-token write at the caller
level: a reusable workflow can only downgrade the caller's token, never
escalate, so a bare contents:read caller would break the callee's ghcr
push and cosign sign.
- The jobs that use the Docker Hub credentials now declare an
environment, so those credentials become environment-scoped with a
deployment-branch policy rather than repo-wide:
publish-testing.yml -> environment: testing (branch: testing)
promote-latest.yml -> environment: release (branch: master)
push-to-dockerhub_rw.yml -> environment: release (branch: master)
This matches how the AWS OIDC roles are already scoped by ref.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
jsokol
force-pushed
the
HARDEN-actions-permissions-and-environments
branch
from
August 21, 2026 17:18
2fd4e3c to
96da81e
Compare
This was referenced Aug 21, 2026
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.
Housekeeping so the repo-level default
GITHUB_TOKENcan be set to read-only, plus a move of the registry credentials onto environments.Per-workflow
permissions:Every workflow now declares one explicitly.
create_new_tag.ymlis the only one that needscontents: write(it tags and pushes tags); the rest arecontents: read.One detail worth a second look:
push-to-gh-pkgs.ymlgrantspackages: write+id-token: writeat the caller level. A reusable workflow can only downgrade the caller's token, never escalate — so with a barecontents: readcaller, the callee'sghcr.iopush andcosign signwould both fail. The callee's own job-level block is unchanged.Registry credentials → environments
The jobs that use the Docker Hub credentials now declare an environment, so those credentials are environment-scoped with a deployment-branch policy instead of repo-wide:
publish-testing.ymltestingtestingpromote-latest.ymlreleasemasterpush-to-dockerhub_rw.ymlreleasemasterreleasealso carries a required reviewer, so a GA promotion waits on one approval. This lines up with how the AWS OIDC roles are already scoped —simplerisk-image-promoter-latestand-testingpin theirsubtorefs/heads/masterandrefs/heads/testing.Ordering note for whoever merges
The environments exist but hold no values yet — secret values can't be copied programmatically. Sequence matters:
DOCKER_USERNAME+DOCKER_TOKENon both thereleaseandtestingenvironments.DOCKER_USERNAME/DOCKER_TOKEN.Doing 3 before 1 will fail the next
publish-testingrun.🤖 Generated with Claude Code