Grant workflow GITHUB_TOKEN package-write scope for GHCR image publish - #1
Merged
Conversation
Agent-Logs-Url: https://github.com/AET-DevOps26/w04-template/sessions/3d271e22-3ccf-4dc3-a66b-6b6d99a80461 Co-authored-by: spethso <23580428+spethso@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix failing GitHub Actions workflow for Docker images
Grant workflow May 12, 2026
GITHUB_TOKEN package-write scope for GHCR image publish
spethso
approved these changes
May 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Docker workflow was building images successfully but failing on GHCR push with
denied: installation not allowed to Create organization package. The workflow token lacked explicit package publish permission for org-scoped GHCR images.Root cause
build_docker.ymlusedsecrets.GITHUB_TOKENfordocker/login-action, but workflow-level permissions did not grantpackages: write.Workflow change (minimal)
.github/workflows/build_docker.yml:contents: readpackages: writeclientandservercontinue to build and push under:ghcr.io/${{ github.repository }}/${{ matrix.service }}Resulting permission model
Original prompt
Fix the failing GitHub Actions workflow in repository
AET-DevOps26/w04-templateso Docker images are successfully built and pushed to GHCR.Context:
.github/workflows/build_docker.ymlfe8016bd66807bc79c38d2c5b87e16ada9e9d9affailed to push ghcr.io/aet-devops26/w04-template/client:main: denied: installation not allowed to Create organization packagebuildx failed with: ERROR: failed to build: failed to solve: failed to push ghcr.io/aet-devops26/w04-template/client:main: denied: installation not allowed to Create organization packageCurrent workflow details to inspect and update:
docker/login-action@v3withregistry: ghcr.io,username: ${{ github.actor }}, andpassword: ${{ secrets.GITHUB_TOKEN }}.ghcr.io/${{ github.repository }}/${{ matrix.service }}.docker/build-push-action@v5withpush: true.Task:
clientandserverimages.Acceptance criteria:
The following is the prior conversation context from the user's chat exploration (may be truncated):
User: Please find a solution for this failing job. Use the logs, job definition, and any referenced files where the failure occurred. Keep your response focused on the solution and include code suggestions when appropriate.
Assistant: The failure is not in the app build itself. The image builds successfully, then the job fails when pushing to GHCR:
.github/workflows/build_docker.ymllines 64–72denied: installation not allowed to Create organization packageghcr.io/aet-devops26/w04-template/client:mainRelevant workflow lines:
secrets.GITHUB_TOKENat.github/workflows/build_docker.yml:38–43.github/workflows/build_docker.yml:64–72Root cause:
The workflow is trying to publish a package to the organization namespace
ghcr.io/aet-devops26/..., but the token used by the workflow is not allowed to create organization packages. This is usually caused by either:packages: writepermission, orSolution:
1) Add package write permission to the workflow
Update
.github/workflows/build_docker.ymlto grant the job/token permission to push packages.