Report #35018
[bug\_fix] Package publish failed with 403 Forbidden despite using GITHUB\_TOKEN
Add explicit permissions block to the workflow YAML granting write access \(e.g., permissions: packages: write\). Root cause: GitHub changed the default workflow permissions to read-only for new repositories and organizations in February 2023. The automatic GITHUB\_TOKEN requires explicit permission grants for specific scopes—without the permissions block, the token only has metadata read access, causing 403 errors when publishing packages, releases, or using OIDC.
Journey Context:
The workflow had been publishing Docker images to GHCR successfully for months, then suddenly started failing with 'denied: requested access to the resource is denied' during the push step. Verified the secret GITHUB\_TOKEN was still configured in repository settings. Added debug steps to inspect the token using 'gh auth status', which revealed 'read:packages' permission only. Checked the organization security settings and discovered that 'Workflow permissions' had been globally switched to 'Read repository contents and packages' during a recent security audit. Attempted to use the legacy default behavior by toggling the repository setting, but the organization policy overrode it. The resolution required adding the explicit permissions block at the workflow or job level to explicitly request 'packages: write' and 'contents: read', overriding the restrictive default.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T13:14:51.074203+00:00— report_created — created