Skip to content

ci: declare per-workflow permissions and move registry creds to environments - #161

Merged
jsokol merged 1 commit into
masterfrom
HARDEN-actions-permissions-and-environments
Aug 21, 2026
Merged

ci: declare per-workflow permissions and move registry creds to environments#161
jsokol merged 1 commit into
masterfrom
HARDEN-actions-permissions-and-environments

Conversation

@jsokol

@jsokol jsokol commented Aug 21, 2026

Copy link
Copy Markdown
Member

Housekeeping so the repo-level default GITHUB_TOKEN can 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.yml is the only one that needs contents: write (it tags and pushes tags); the rest are contents: read.

One detail worth a second look: push-to-gh-pkgs.yml grants packages: write + id-token: write at the caller level. A reusable workflow can only downgrade the caller's token, never escalate — so with a bare contents: read caller, the callee's ghcr.io push and cosign sign would 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:

workflow environment allowed ref
publish-testing.yml testing testing
promote-latest.yml release master
push-to-dockerhub_rw.yml release master

release also 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-latest and -testing pin their sub to refs/heads/master and refs/heads/testing.

Ordering note for whoever merges

The environments exist but hold no values yet — secret values can't be copied programmatically. Sequence matters:

  1. Populate DOCKER_USERNAME + DOCKER_TOKEN on both the release and testing environments.
  2. Merge this PR.
  3. Remove the repo-level DOCKER_USERNAME / DOCKER_TOKEN.
  4. Set Settings → Actions → Workflow permissions to Read repository contents.

Doing 3 before 1 will fail the next publish-testing run.

🤖 Generated with Claude Code

…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
jsokol force-pushed the HARDEN-actions-permissions-and-environments branch from 2fd4e3c to 96da81e Compare August 21, 2026 17:18
@jsokol jsokol changed the title ci(security): scope GITHUB_TOKEN per workflow and gate Docker Hub creds behind environments ci: declare per-workflow permissions and move registry creds to environments Aug 21, 2026
@jsokol
jsokol merged commit 506bc75 into master Aug 21, 2026
5 checks passed
@jsokol
jsokol deleted the HARDEN-actions-permissions-and-environments branch August 21, 2026 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant