Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
anchor

GitHub Action

Docker Tag Build Push

v1.4.2

Docker Tag Build Push

anchor

Docker Tag Build Push

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

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Docker Tag Build Push

uses: benfrisbie/docker-tag-build-push-action@v1.4.2

Learn more about this action in benfrisbie/docker-tag-build-push-action

Choose a version

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: