GitHub Actions: Secrets, Permissions, Security, and OIDC/Set least-privilege token permissions

Limit the default GITHUB_TOKEN scope.

Section: Permissions and secrets

Set least-privilege token permissions

yaml
yaml
permissions:
  contents: read
Explanation

Restrict permissions at the workflow or job level unless write access is truly needed.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Permissions and secrets
Grant write access only where needed
Elevate token permissions on a specific job.
OpenIn sheetyamlsame section
Expose a secret as an environment variable
Use the `secrets` context in step env.
OpenIn sheetyamlsame section
Mask a dynamic sensitive value
Hide a generated or fetched secret from logs.
OpenIn sheetbashsame section
Use protected environments for deploys
Require approval and environment-scoped secrets.
OpenIn sheetyamlsame section
Enable OIDC token issuance
Grant `id-token: write` when using cloud federation.
OpenIn sheetyaml1 tag match
Configure AWS credentials via OIDC
Use the AWS credentials action without long-lived keys.