Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Copilot Lvl 2
Message 1 of 15

Github Actions Docker login

Solved! Go to Solution.

I'm trying to push to docker.pkg.github.com from a GitHub action.

 

Here is the login step, which fails with 401 error:

 

      - name: Log in to registry
        uses: actions/docker/login@master
        env:
          DOCKER_REGISTRY_URL: docker.pkg.github.com
          DOCKER_USERNAME: ${{ github.actor }}
          DOCKER_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
        if: github.event_name == 'push'

Any ideas?

14 Replies
Community Manager
Message 2 of 15

Re: Github Actions Docker login

I'm not sure that `github.actor` is the best choice for assigning the `DOCKER_USERNAME` value, unless that is always going to be someone with permissions to the package registry for that repository? What is `github.actor` set to when you get the 401 error?

Copilot Lvl 2
Message 3 of 15

Re: Github Actions Docker login

I can't really log `github.actor`, it's filtered in the log.

 

What am I supposed to set the docker registry login when pushing to the GitHub registry?

 

If I have to manually create a personal access token (which I'm actually doing at the moment), that kinda defeats the whole purpose of using an integrated environment. Why is there a GITHUB_TOKEN secret then in the CI environment?

 

Also, there is a table in the documentation that says the GITHUB_TOKEN secret is a token with write permissions to packages:

https://help.github.com/en/articles/virtual-environments-for-github-actions#token-permissions

 

Is that not correct then?

Copilot Lvl 2
Message 4 of 15

Re: Github Actions Docker login

Yesterday I've tried to run `docker login ...` with a personal access token that's working from my laptop and  I got this:

 

Screenshot from 2019-08-29 18-53-04.png

 

No idea why :) I hope this will be fixed when "GitHub actions" leaves the beta stage

Copilot Lvl 2
Message 5 of 15

Re: Github Actions Docker login

I recently tried doing something similar.

 

It seems that the `GITHUB_TOKEN` does not have the correct access permissions (even though I believe it should based on https://help.github.com/en/articles/virtual-environments-for-github-actions#token-permissions ).

 

I generated a personal access token and added a repository encrypted secret to login. I'm also using the included Docker baked into the virtual image.

 

 

      - name: Login to GitHub Docker Registry
        run: docker login docker.pkg.github.com --username $DOCKER_USERNAME --password $DOCKER_PASSWORD
        env:
          DOCKER_USERNAME: ${{ secrets.GITHUB_DOCKER_USERNAME }}
          DOCKER_PASSWORD: ${{ secrets.GITHUB_DOCKER_PASSWORD }}

 

 

Copilot Lvl 2
Message 6 of 15

Re: Github Actions Docker login

I came to the same conclusion and did the same thing, but I think that's quite a huge fail. If I want to use GitHub for CI and packages, I expect these services to be integrated. I kinda thought that was the value proposition in the first place: you can do everything in one place. Otherwise both GitHub Actions and GitHub Packages are "Yet Another Service".

Copilot Lvl 2
Message 7 of 15

Re: Github Actions Docker login

Tried to do the same thing to get Actions creating Docker images locally - in the hope that having images stored in GitHub might be faster than having to fetch from Docker Hub.

 

However currently it feels like two different beta products aren't quite ready for each other.

Copilot Lvl 2
Message 8 of 15

Re: Github Actions Docker login

Same problem. This documentation about this is really weak :-(
For me do not giving sense to create personal access here if there can be some global access based on access to repository.

Copilot Lvl 2
Message 9 of 15

Re: Github Actions Docker login

Struggling with the exact same thing now. One of the unique selling points for Github actions is seamless integration with other Github services - which is completely absent in this regard.

 

Please provide a no-hassle way to utilize package registry. All the configuration needed to do this already exists in the context (username and $GITHUB_TOKEN), so no need to boilerplate it in the YAML spec.

 

Maybe something in the lines of:

 

- uses: actions/docker/login-package-registry@master

 

Mission Specialist Lvl 1
Message 10 of 15

Re: Github Actions Docker login

Same issue. Using GITHUB_TOKEN still results in a 401 when publishing using Github Actions.