The Docker folks have released their first GitHub Action build-push-action
which builds and pushes Docker images and will log in to a Docker registry if required.
Building and pushing an image becomes really easy:
uses: docker/build-push-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
repository: myorg/myrepository
tags: latest
Amongst other options you can also define a registry
, which defaults to the Docker Hub.