Skip to content

Latest commit

 

History

History
116 lines (101 loc) · 3.82 KB

README.md

File metadata and controls

116 lines (101 loc) · 3.82 KB

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: