Skip to content

A composite action to tag and build a docker image, then optionally login to a registry and push the image

License

Notifications You must be signed in to change notification settings

benfrisbie/docker-tag-build-push-action

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

GitHub release GitHub marketplace CI workflow

About

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.


Usage

Basic

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

Push to Docker Hub

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 Multiple Registries

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 }}

Inputs

The inputs are the same as the ones defined in:

Defaults

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 }}

Outputs

The outputs are the same as the ones defined in:

About

A composite action to tag and build a docker image, then optionally login to a registry and push the image

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Sponsor this project