Cannot login to ghcr.io

See original GitHub issue

I’m trying to have my goreleaser upload images to ghcr.io. To do that I have:

Unfortunately, it fails to push with:

The push refers to repository [ghcr.io/daenney/gdqbot]
b3b3f5b6a923: Preparing
fb0113d63c91: Preparing
960cfde826a2: Preparing
denied: unauthenticated: User cannot be authenticated with the token provided.
: exit status 1
Error: The process '/opt/hostedtoolcache/goreleaser-action/0.149.0/x64/goreleaser' failed with exit code 1

I feel like I’m probably missing something incredibly obvious but I’m not sure what.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
tschaubcommented, Mar 31, 2022

As of today, it looks like these things are true:

  1. you don’t need to create a personal access token to push to ghcr.io from this action
  2. you can use GITHUB_TOKEN, but need to specifically set packages: write in the job/workflow permissions
  3. you need to docker login before running this action (e.g. using docker/login-action)

Here is a complete working example release.yml:

name: Release

on:
  push:
    tags:
      - 'v*'

permissions:
  contents: write
  packages: write

jobs:
  release:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - run: git fetch --force --tags
      - uses: actions/setup-go@v2
        with:
          go-version: 1.18
      - uses: docker/login-action@v1
        with:
          registry: ghcr.io
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}
      - uses: goreleaser/goreleaser-action@v2
        with:
          distribution: goreleaser
          version: latest
          args: release --rm-dist
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1reaction
daenneycommented, Dec 16, 2020

It appears as though I’ve misunderstood how this was supposed to work together. This works:

    - name: Login to GitHub Container Registry
      uses: docker/login-action@v1
      with:
        registry: ghcr.io
        username: ${{ github.repository_owner }}
        password: ${{ secrets.GH_PAT }}
    - name: Run GoReleaser
      uses: goreleaser/goreleaser-action@v2
      with:
        version: latest
        args: release --rm-dist
      env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to login to ghcr.io docker registry (service unavailable)
I was running docker login command in powershell. I've tried with both PAT and password, but it does not work.
Read more >
Can't Login ghcr.io for docker registry with Github Enterprise ...
I'm using Github Enterprise Server and GitHub Actions. I realized message Docker login for 'ghcr.io' failed with exit code 1 and I did...
Read more >
Connector to ghcr.io no longer works | Inedo Community Forums
Hello, I have a docker connector to ghcr.io (the github container registry) which authenticates with a personal access token.
Read more >
docker login ghcr.io succeeded, but docker pull denied - Reddit
Hello, using Github actions, I've built a new docker image, which is a private package now. In the terminal, I login successfully:
Read more >
Unable to create container instance of private Github ...
I am trying to create an Azure Container Instance of a private image on my ghcr.io (Github Container Repository).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found