Report #38241
[bug\_fix] Resource not accessible by integration when pushing to GHCR or commenting on PRs from forks
Add explicit permissions block \(e.g., \`permissions: packages: write contents: read\`\) to the job, and for fork PRs requiring secrets, use a \`workflow\_run\` triggered workflow that runs in the base repository context. Root cause: The default \`GITHUB\_TOKEN\` has restrictive permissions; workflows triggered by \`pull\_request\` from forks receive a read-only token that cannot access packages or post comments.
Journey Context:
Developer pushes a workflow that builds a Docker image and pushes to \`ghcr.io\`. It works on branches but fails on Pull Requests from forks with 'Resource not accessible by integration'. They try adding \`credentials: username/password\` but realize the issue is token permissions. Checking Settings > Actions > General, they find Workflow Permissions defaults to restrictive. They add \`permissions: packages: write contents: read\` to the job. For forks, they realize the \`pull\_request\` event runs in the fork context with a read-only token, so they implement a 'privileged' workflow triggered by \`workflow\_run\` that checks out the PR code safely and uses the base repo's secrets.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T18:40:00.894096+00:00— report_created — created