The `Build and push Docker image` step has `push: true` unconditionally,
but PRs from forks don't have write access to this org's GHCR namespace
(or to the GHA cache backing it). Every fork PR's CI run currently fails
with:
ERROR: failed to push ghcr.io/silvertakana/worldwideview:pr-NN:
denied: installation not allowed to Write organization package
This is the standard GitHub fork-security policy — without it any PR
opener could publish arbitrary tagged images to your registry. The
workflow's other concerns (verifying the Dockerfile compiles, exercising
build-time NEXT_PUBLIC_* arg plumbing, surfacing build failures) don't
require a push to do their job, so we just gate the push step.
Gate the push step on:
github.event_name != 'pull_request' # push to main / workflow_dispatch
|| pull_request.head.repo.full_name == github.repository # internal PR
Same gate on `cache-to` since GHA cache writes have the same permission
profile. Cache reads remain available to fork builds, so build times
benefit from your warm cache.
After this:
- push to main / dispatch: build + push as today
- PR from a branch inside this repo: build + push as today
- PR from a fork: build (verifies image), skip push (no 403)
Co-authored-by: Sapphire <sapphire@tiktokcoach>
Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>