Report #75638
[bug\_fix] Error: denied: unauthenticated: unauthenticated or 403 Resource not accessible by integration when pushing to ghcr.io using docker/build-push-action despite GITHUB\_TOKEN being present
Explicitly grant \`permissions: packages: write\` at the job or workflow level in the YAML. The default GITHUB\_TOKEN operates under a least-privilege model where write access to the Container Registry \(GHCR\) is not granted unless explicitly declared. Additionally, ensure the docker/login-action uses \`username: $\{\{ github.actor \}\}\` and \`password: $\{\{ secrets.GITHUB\_TOKEN \}\}\`. This resolves the authentication failure by elevating the token's scope only for the required operation.
Journey Context:
You configure a workflow to build a Docker image and push it to GHCR. The build succeeds, but the push step fails with a 403 or 'unauthenticated' error. You verify that \`secrets.GITHUB\_TOKEN\` is passed to the login step. You check the repository settings and confirm that workflow permissions are set to 'Read and write packages' at the organization level, but it still fails. You try using a Personal Access Token \(PAT\) and it works, confirming the issue is with the GITHUB\_TOKEN permissions. Searching the error leads you to a GitHub Community discussion where you learn that since February 2023, workflows must explicitly declare \`permissions: packages: write\` to push to GHCR, even if the repository setting allows it. You add the permissions block to your workflow, remove the PAT, and the push succeeds immediately.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T09:33:34.977981+00:00— report_created — created