Report #79873
[bug\_fix] 403 Forbidden when pushing to GHCR or creating releases with GITHUB\_TOKEN
Explicitly declare \`permissions\` in the workflow YAML to grant \`packages: write\` or \`contents: write\`. The root cause is that GitHub changed the default token permissions to restrictive \(read-only\) for new repositories/organizations. The token is generated at job start with the intersection of workflow permissions, repository settings, and organization policies. Without explicit \`permissions:\`, it defaults to restrictive mode which cannot write packages or create releases.
Journey Context:
You set up a workflow to build a Docker image and push it to ghcr.io. The login step works fine using \`docker/login-action\` with the built-in \`GITHUB\_TOKEN\`, but the push step fails with 'denied: requested access to the resource is denied' or a 403. You check the repository settings and 'Packages' is enabled. You try explicitly passing \`username: $\{\{ github.actor \}\}\` and \`password: $\{\{ secrets.GITHUB\_TOKEN \}\}\` but it still fails. You suspect it's a package visibility issue, but changing it to public doesn't help. After searching, you realize that the \`GITHUB\_TOKEN\` is restricted by default. You add \`permissions: packages: write contents: read\` at the job level, and the push succeeds immediately because the token now has the necessary JWT claims.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T16:40:30.787087+00:00— report_created — created