Skip to content

Commit 10c6daf

Browse files
authored
Fix: Add Docker login to GHCR before pushing images (fixes #153) (#154)
## Summary Add `docker/login-action` to authenticate with GitHub Container Registry before GoReleaser attempts to push Docker images. ## Problem Docker push was failing with authentication error: ``` unauthorized: unauthenticated: User cannot be authenticated with the token provided. The push refers to repository [ghcr.io/bsubio/cli] ``` The `credentials:` in the workflow's `container:` section only authenticates pulling the CI container image. It doesn't log Docker in for pushing images from within the container. ## Solution Add explicit Docker login step using `docker/login-action` before GoReleaser runs. This authenticates Docker to push images to ghcr.io. ## Changes - Add "Log in to GitHub Container Registry" step - Use `docker/login-action@v3` - Authenticate to `ghcr.io` registry - Use `github.actor` and `GITHUB_TOKEN` - Runs after buildx setup, before GoReleaser ## Workflow Flow 1. ✅ Set up QEMU (for ARM64 emulation) 2. ✅ Set up Docker Buildx (for multi-arch builds) 3. ✅ **Log in to GHCR** (NEW - authenticate for push) 4. ✅ Run GoReleaser (build and push images) ## Result - GoReleaser can successfully push multi-arch Docker images to ghcr.io - Both amd64 and arm64 images are built and pushed - Multi-arch manifests are created - Users can pull images: `docker pull ghcr.io/bsubio/cli:latest` Fixes #153
1 parent c8b2662 commit 10c6daf

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

.github/workflows/build.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ on:
1616

1717
permissions:
1818
contents: write
19-
packages: read
19+
packages: write
2020

2121
jobs:
2222
build:
@@ -74,6 +74,14 @@ jobs:
7474
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
7575
uses: docker/setup-buildx-action@v3
7676

77+
- name: Log in to GitHub Container Registry
78+
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
79+
uses: docker/login-action@v3
80+
with:
81+
registry: ghcr.io
82+
username: ${{ github.actor }}
83+
password: ${{ secrets.GITHUB_TOKEN }}
84+
7785
- name: Get latest tag
7886
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
7987
id: get_tag

0 commit comments

Comments
 (0)