Use this when using secrets in GitHub Actions.
Secrets · GitHub Actions
Secrets in GitHub Actions are encrypted values stored at repository, environment or organization level and read as ${{ secrets.NAME }}. They are masked in logs and not passed to forked pull requests.
1. Secrets are encrypted and masked in logs.
2. Scope to environments.
3. Not available to fork PRs.
4. Prefer OIDC to cloud providers.
5. Rotate and remove unused secrets.
secret → environment/job → masked env var
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Verification path Verify boundary
The negative fixture should deliberately exercise risks such as event filter surprises, unpinned actions, secret/permission overreach, runner drift, matrix partial failure, artifact confusion and assuming conclusion=success shows external convergence, choosing the cases most relevant to secret object identity, encryption-at-rest limitations, RBAC/service-account access, projection/environment exposure and rotation without logging secret values.
Step 2 Common mistakes Narrow the fault
- Secrets in workflow files.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
- Secrets exist at repository, environment and organization level.
- They are masked in logs.
- Secrets are not available to workflows from forks.
gh secret list— repo secretsgh secret list --env <env>— environment secrets- OIDC (id-token: write) instead of cloud keys — federation
ReferenceImportant terms & boundaries1 section · depth on demand
In depth
Secrets in GitHub Actions store sensitive values encrypted at organisation, repository or environment level. Workflows read them through the secrets context, and GitHub masks their values in logs.
Important behaviours:
- Secrets are not passed to workflows triggered by pull requests from forks, protecting them from untrusted code.
- Environment secrets are only available to jobs that target that environment, which can require approval.
- Masking only hides exact values; printing a transformed secret can leak it.
jobs:
deploy:
environment: production
runs-on: ubuntu-latest
steps:
- run: ./deploy.sh
env:
API_TOKEN: ${{ secrets.PROD_API_TOKEN }}
For cloud access, prefer OpenID Connect (permissions: id-token: write) over long-lived keys: the workflow exchanges a short-lived token for cloud credentials, so no cloud secret is stored in GitHub at all.
ReferenceConfiguration & state1 section · depth on demand
Lifecycle
Secrets belong in the platform's intended secret store and must not be copied into generated examples, logs or audit output.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in GitHub Actions > Secrets. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax · confidence 94%Deep reference
Healthy vs suspicious evidence
Output interpretation
For secret object identity, encryption-at-rest limitations, RBAC/service-account access, projection/environment exposure and rotation without logging secret values, prefer typed fields and stable IDs over human presentation text.