A composite action to tag, build, and optionally login and push a docker image to a registry.
This action basically chains calls to the following popular actions with some common defaults.
- docker/login-action
- docker/setup-qemu-action
- docker/setup-buildx-action
- docker/metadata-action
- docker/build-push-action
Push to ghcr.io by default
name: Docker
on:
push:
branches:
- main
tags:
- 'v*.*.*'
pull_request:
jobs:
docker:
runs-on: ubuntu-latest
steps:
- uses: benfrisbie/docker-tag-build-push-action@v1
name: Docker
on:
push:
branches:
- main
tags:
- 'v*.*.*'
pull_request:
jobs:
docker:
runs-on: ubuntu-latest
steps:
- uses: benfrisbie/docker-tag-build-push-action@v1
with:
images: docker.io/${{ github.repository }}
registry: 'docker.io'
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
Push to Docker Hub and ghcr.io. First login to docker.io and the automatically login to ghcr.io by default.
name: Docker
on:
push:
branches:
- main
tags:
- 'v*.*.*'
pull_request:
jobs:
docker:
runs-on: ubuntu-latest
steps:
- uses: docker/login-action@v2
with:
registry: 'docker.io'
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- uses: benfrisbie/docker-tag-build-push-action@v1
with:
images: |
docker.io/${{ github.repository }}
ghcr.io/${{ github.repository }}
The inputs are the same as the ones defined in:
In an attempt to make this action easier to use, the following defaults are set:
- Build an image named
ghcr.io/${{ github.repository }}
- The image tags are determined based on the event causing the build as defined at docker/metadata-action#tags-input
- Push image to registry on git push events
${{ github.event_name == 'push' }}
- Default registry of ghcr.io
- Username =
${{ github.actor }}
- Password =
${{ github.token }}
- Username =
The outputs are the same as the ones defined in: