Solvedstarter workflows Use GITHUB_TOKEN to auth in docker.pkg.github.com

Try to publish docker container to docker.pkg.github.com

I got error: Error response from daemon: login attempt to https://docker.pkg.github.com/v2/ failed with status: 401 Unauthorized

name: Deploy

on: [push]

jobs:
  publish:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@master
    - name: login
      run: echo ${GITHUB_TOKEN} | docker login -u ${GITHUB_ACTOR} --password-stdin docker.pkg.github.com
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
17 Answers

✔️Accepted Answer

I can confirm that this works for me:

    - name: Docker Login
      uses: azure/docker-login@v1
      with:
        login-server: docker.pkg.github.com
        username: $GITHUB_ACTOR
        password: ${{ secrets.GITHUB_TOKEN }}

Other Answers:

@landsman A personal access token - for now, you can create one with the write:packages permission, and store it in the secrets store to push to docker at this time.

Based on the reply saying "Docker isn't supported at the moment", and that this blog post added support for GITHUB_TOKEN usage to Nuget, I suspect the built-in GITHUB_TOKEN is planned to work for Docker in the future.

Good. Now we can do

    - name: Checkout
      uses: actions/checkout@v2
    - run: |
        IMAGE_NAME="docker.pkg.github.com/${GITHUB_REPOSITORY}/my-image:1.0"
        echo "${{ github.token }}" | docker login https://docker.pkg.github.com -u ${GITHUB_ACTOR} --password-stdin
        docker build -t $IMAGE_NAME .
        docker push $IMAGE_NAME

@eine It's same. Just shorter, lol.

For me, the main value proposition of GitHub Actions is that everything is integrated under one umbrella. Until that's not true, it's not better than the competition who has their services up and running probably for years now. I understand that this is a beta program, but still, GitHub needs to "kick ass" if they want to enter this market. Otherwise it's just another service and there won't be any incentive in it for users to migrate their projects to GitHub Actions.