30
Backend
06
Security
12
iOS
21
Infra

Keep CI secrets in a master-only environment so the patch agent can edit workflows

ADR-0095 ACCEPTED · 2026-10-25
Keep CI secrets in a master-only environment so the patch agent can edit workflows

Amends ADR-0092: the patch agent may now edit workflow files, which ADR-0092 had forbidden.

Decision

Hold every GitHub Actions secret in one environment whose deployment branch policy admits only master, and hold none at repository level. A job reads secrets only by naming that environment, so only runs of the workflows as they exist on master get them. A pull request's own code reaches secrets only after a maintainer has reviewed it and marked it trusted. Deploy production by the image digest the master build recorded, never by tag, because a workflow on any branch can move a tag. With both in place, the patch agent gets permission to push workflow files and bumps Actions pins and pinned tool versions like any other dependency.

Why

A workflow file runs with the secrets of the context it is triggered in. With repository-level secrets, anyone who can push a workflow file to any branch can add a job that triggers on that push and reads every secret, before any pull request or review exists. That is why the agent could not edit workflows, and why Actions pins were bumped only by hand. Scoping secrets to master, and production to a recorded digest, moves the boundary from who can push to what has merged or been marked trusted.

Rejected alternatives

  • Keep the agent off workflow files and bump pins by hand. Pins drift, and the manual sweep is the daily work this pipeline exists to remove.
  • Grant the permission with repository-level secrets. Any branch the agent pushes could read every CI secret without review.
  • Restrict workflow-file pushes with a push ruleset. It reintroduces the same block on the agent this decision removes.

Consequences

A pull request builds only once a maintainer marks it trusted, since an ordinary pull-request run is in the branch's context and gets no secrets. A workflow edit reaches secrets only after merge, so a gate weakened in a pull request is caught only at review. Every new secret has to go in the environment, because the boundary holds only while repository level stays empty. Rolling back to a build older than its artifact retention needs a rebuild.