Today, when using GitHub Actions to automatically build Docker, the push failed with the error: ERROR: failed to solve: failed to push ghcr.io/xx:latest: unexpected status from POST request to https://ghcr.io/v2/xx/blobs/uploads/: 403 Forbidden.
After some investigation, here are the possible reasons and solutions.
〇 Reason#
This issue occurred because the packages did not have action permissions for the repository. In my case, it was due to a previously deleted repository with the same name. This repository had already built a package, but after deletion, the package automatically lost its permissions. As a result, the new repository lacked permissions.
一 Search#
After Googling, I found an issue that raised a similar problem, and someone provided an answer, emmm, but did not provide an entry point:
二 Solution#
- Click on the repository's packages
- Select packages according to Docker configuration and open package settings
- Add repository actions in permissions and grant write permissions
- Rebuild it
Done!
This article was synchronized and updated to xLog by Mix Space. The original link is https://www.vikifish.com/posts/env/github-docker-build-403