How to login to Docker registries using Github Actions
The actions/docker
action has now been deprecated. If you visit the repository you will see that the repository is archived and has the following message.
This action is deprecated in favor of using the run script step in the new YAML language to run the docker cli.
https://github.com/actions/docker
So the recommended way to login to Docker registries is to use the run
script command as follows.
For the public DockerHub registry:
name: my workflowon: push: branches: - masterjobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 - name: Login to DockerHub Registry run: echo ${{ secrets.DOCKERHUB_PASSWORD }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
For a private registry, such as the new GitHub Package Registry, you also need to specify the hostname:
name: my workflowon: push: branches: - masterjobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 - name: Login to GitHub Package Registry run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login docker.pkg.github.com -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
Also see this answer for complete workflow examples of docker image publishing.
https://github.com/marketplace/actions/docker-login
Try this action instead as actions/docker/login@master
appears to have been deprecated.
I found Git hub action: Build and push Docker images
https://github.com/marketplace/actions/build-and-push-docker-images
It works well, I was able to build and push docker image to Docker Hub.