The CI/CD pipeline is failing with:
ERROR: failed to push ghcr.io/mjahmadee/cataract-lmm:main: unexpected status from HEAD request to https://ghcr.io/v2/mjahmadee/cataract-lmm/blobs/sha256:...: 403 Forbidden
This error occurs due to insufficient permissions to push Docker images to GitHub Container Registry (GHCR). The main causes are:
- Repository Permissions: The default
GITHUB_TOKENdoesn't havepackages:writescope - Workflow Permissions: GitHub Actions workflow permissions are too restrictive
- Package Visibility: Container registry package settings may be misconfigured
Step 1: Go to your repository settings
- Navigate to
https://github.com/MJAHMADEE/Cataract-LMM/settings/actions - Under "Workflow permissions", select:
- ✅ "Read and write permissions"
- ✅ "Allow GitHub Actions to create and approve pull requests"
- Click "Save"
Step 2: Verify package settings
- Go to
https://github.com/MJAHMADEE/Cataract-LMM/settings/packages - Ensure the package
cataract-lmmexists and has proper permissions - Set visibility to Public or ensure your token has access
Step 1: Create a Personal Access Token
- Go to
https://github.com/settings/tokens - Click "Generate new token (classic)"
- Select scopes:
- ✅
write:packages - ✅
read:packages - ✅
delete:packages(optional)
- ✅
- Copy the token
Step 2: Add token as repository secret
- Go to
https://github.com/MJAHMADEE/Cataract-LMM/settings/secrets/actions - Click "New repository secret"
- Name:
GHCR_TOKEN - Value: Your PAT from Step 1
Step 3: Update workflow to use PAT
- name: 🔑 Log in to Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GHCR_TOKEN }} # Changed from GITHUB_TOKENStep 1: Create Docker Hub account and repository
- Sign up at https://hub.docker.com/
- Create repository:
mjahmadee/cataract-lmm
Step 2: Add Docker Hub secrets
- Go to repository settings → Secrets and variables → Actions
- Add secrets:
DOCKERHUB_USERNAME: Your Docker Hub usernameDOCKERHUB_TOKEN: Your Docker Hub access token
Step 3: Update workflow environment variables
env:
REGISTRY: docker.io
IMAGE_NAME: mjahmadee/cataract-lmmAfter implementing Solution 1 (recommended):
-
Push a small change to trigger the workflow:
git commit --allow-empty -m "test: trigger workflow for docker fix" git push -
Monitor the workflow at:
https://github.com/MJAHMADEE/Cataract-LMM/actions -
Expected result: Docker build and push should succeed
The workflow has been updated to:
- ✅ Continue on Docker push failure (non-blocking)
- ✅ Build local Docker image if GHCR push fails
- ✅ Provide helpful error messages and solutions
- ✅ Run security scans on locally built images
After the fix, you should be able to pull your image:
# Once permissions are fixed
docker pull ghcr.io/mjahmadee/cataract-lmm:main
# Verify the image
docker run --rm ghcr.io/mjahmadee/cataract-lmm:main python --version- Build Time: Multi-architecture builds (amd64, arm64) take ~15-30 minutes
- Image Size: Optimized with multi-stage builds and dependency caching
- Security: Images are scanned with Trivy for vulnerabilities
- Caching: GitHub Actions cache is used to speed up subsequent builds
If you continue experiencing problems:
- Check workflow logs for detailed error messages
- Verify repository permissions are correctly set
- Test with a simple push to a test repository first
- Contact GitHub Support for persistent GHCR permission issues
Last Updated: September 9, 2025 Status: ✅ Workflow updated with fallback handling Next Action: Fix repository workflow permissions (Solution 1)