GitHub Actions: push to GHCR returns denied 403
Workflow builds an image of Docker, but publication to ghcr.io does not have permission.
How to identify the source of the problem
Check packages: write in permissions and whether the package is assigned to the correct repo.
Check the workflow event type, permissions joba, run ID and first failed step.
Repair steps
Give the necessary GITHUB TOKEN permission and improve the package access without pasting a private token in Dockerfile.
How to Test Solution
The image is pushed exclusively from the authorized branch, and PR does not publish packages without permission.
Security and restrictions
Apply minimum token privileges and re-impotence. Do not remove main branch protection only for the convenience of the machine.