| Metadata |
Details |
| System Name |
dhh-articles-site GitHub Secrets, Variables & Environments Specifications |
| Document ID |
SR-STATIC-008 |
| Author |
Engineering Team |
| Status |
Draft / Implementation |
The only place where secrets, variables and credential handling are specified. SR-006 — Infrastructure Provisioning Pipeline and SR-007 — Site Build & Deployment Pipeline refer here instead of restating them. Traces to BRD-INFRA-001 BR-1.3 and BRD-004. Delivery-pipeline needs are in BRD-006. Cite requirement IDs with the document ID (e.g. SR-008 SR-F-03).
1. Inventory
Secrets (sensitive, encrypted, never printed)
| Name |
Holds |
Used by |
Notes |
CLOUDFLARE_API_TOKEN_INFRA |
Cloudflare token to manage Pages, R2, DNS, WAF and Workers |
Infrastructure workflow (SR-006) |
Broadest token; never given to the site workflow |
CLOUDFLARE_API_TOKEN_DEPLOY |
Cloudflare token limited to Pages edit |
Site workflow (SR-007) |
No infrastructure permissions |
TOFU_STATE_PASSPHRASE |
Passphrase for OpenTofu state encryption |
Infrastructure workflow only |
Passed as TF_VAR_tofu_passphrase; losing it makes state unreadable |
R2_STATE_ACCESS_KEY_ID |
R2 access key for the state bucket |
Infrastructure workflow only |
Bucket-scoped object read/write |
R2_STATE_SECRET_ACCESS_KEY |
R2 secret key for the state bucket |
Infrastructure workflow only |
Pair of the above |
Variables (not sensitive, visible in logs)
| Name |
Holds |
Used by |
CLOUDFLARE_ACCOUNT_ID |
Cloudflare account identifier |
Both workflows |
PAGES_PROJECT_NAME |
dhh-articles-site |
Site workflow |
STATE_BUCKET_NAME |
dhh-articles-tfstate |
Infrastructure workflow |
ASSETS_BUCKET_NAME |
blog-assets |
Infrastructure workflow |
The account ID appears in the R2 endpoint URL and is an identifier, not a credential, so it is a variable. If the team prefers to hide it, it may stay a secret; the classification rule in SR-F-01 decides.
2. Functional System Requirements
| ID |
Description |
Traceability |
| SR-F-01 (Classification) |
Anything that grants access or decrypts data is a secret. Identifiers and names with no access value are variables. Nothing is stored in the repository, workflow files, or .env files. |
BR-1.3 (BRD-INFRA-001) |
| SR-F-02 (Protected Environment) |
Secrets used to change live infrastructure or production are stored as environment secrets on a production environment, restricted to the main branch, rather than as repository-wide secrets. Jobs that apply or deploy declare environment: production. |
BR-1.3 (BRD-INFRA-001) |
| SR-F-03 (Workflow Scoping) |
Each secret is available only to the workflow listed in the inventory. The infrastructure workflow never receives the deploy token; the site workflow never receives the infrastructure token, state passphrase or R2 state credentials. |
BR-1.3 (BRD-INFRA-001) |
| SR-F-04 (Injection) |
Secrets are passed to a step through its env: block, never expanded inside a run: command line or written to files. Each step receives only the secrets it uses, so the scan and build steps receive none. |
BR-1.3 (BRD-INFRA-001) |
| SR-F-05 (State Credential Mapping) |
R2 state credentials are provided to OpenTofu as the S3-protocol environment variables the backend reads (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY); the names are protocol conventions and the values are R2 keys. No AWS account is used. |
BR-1.3 (BRD-INFRA-001) |
| SR-F-06 (Passphrase Escrow) |
A copy of TOFU_STATE_PASSPHRASE is kept in an access-controlled location outside GitHub, so state stays recoverable if the secret is lost. |
BR-1.3 (BRD-INFRA-001) |
3. Non-Functional & Security Requirements
| ID |
Specification |
Traceability |
| SR-NF-01 (Least Privilege Tokens) |
CLOUDFLARE_API_TOKEN_INFRA is limited to the one account and zone and the resource types it manages; CLOUDFLARE_API_TOKEN_DEPLOY to Pages edit; R2 state credentials to object read/write on the state bucket. No “admin” tokens. |
BR-1.3 (BRD-INFRA-001) |
| SR-NF-02 (Default Token Permissions) |
The GITHUB_TOKEN default is read-only; a job raises permissions explicitly and only as needed. |
BR-1.3 (BRD-INFRA-001) |
| SR-NF-03 (Untrusted Code Gets No Secrets) |
Workflows triggered by pull requests from forks receive no secrets, and no workflow uses pull_request_target to run untrusted code with secrets. |
BR-1.3 (BRD-INFRA-001) |
| SR-NF-04 (No Disclosure) |
No step echoes, logs, or uploads a secret as an artifact, comment, or plan output. Plan output posted to pull requests is reviewed for sensitive values. |
BR-1.3 (BRD-INFRA-001) |
| SR-NF-05 (Rotation) |
Each token and key has a documented rotation interval (suggested: at least every 90 days) and is rotated immediately on suspected exposure or when a maintainer leaves. State passphrase rotation uses OpenTofu’s fallback-key mechanism. |
BR-1.3 (BRD-INFRA-001) |
| SR-NF-06 (Change Control) |
Changes under .github/workflows/ require review (CODEOWNERS), since a workflow edit can exfiltrate secrets. Actions are pinned to a version or commit SHA. |
SR-004 SR-NF-04 |
| SR-NF-07 (Leak Detection) |
Repository secret scanning and push protection are enabled; the Trivy secret scan (SR-004 SR-F-02) is a second check. |
BR-1.1 (BRD-004) |
| SR-NF-08 (Ephemeral Exposure) |
Secrets exist only in runner memory for the duration of a job on ephemeral runners; nothing is cached or persisted between runs. |
SR-INFRA-001 SR-NF-03 |
4. Open Items
- Environment protection availability. Required reviewers and branch restrictions on environments may depend on the repository’s visibility and GitHub plan. Confirm they are available for this repository; if not, fall back to repository secrets plus branch protection and record the reduced control.
- Token names changed. The earlier pasted workflow used a single
CLOUDFLARE_API_TOKEN for both infrastructure and deploy. SR-F-03 splits it into two tokens; the workflows and secrets must be created to match.
- Account ID classification. Confirm the team’s choice (variable vs secret) per SR-F-01.
- Cloudflare token permission list. The exact permissions for the infrastructure token (Pages, R2, DNS, WAF, Workers) must be verified against the provider version in use.
- Rotation tracking. Where rotation dates are recorded (calendar reminder, runbook) is undecided.
- Escrow location. The out-of-GitHub location for the passphrase copy is undecided.