Skip to content

Build and publish Docker image #83

Build and publish Docker image

Build and publish Docker image #83

Workflow file for this run

name: Build and publish Docker image
on:
schedule:
- cron: '03 20 * * *'
push:
branches: [ "main" ]
tags: [ 'v*.*.*' ]
pull_request:
branches: [ "main" ]
env:
DOCKER_REGISTRY: ghcr.io
DOCKER_IMAGE_NAME: ${{ github.repository }}
DOCKER_TARGETS: linux/amd64,linux/arm64
jobs:
buildx:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Setup QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: ${{ env.DOCKER_TARGETS }}
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v2
with:
platforms: ${{ env.DOCKER_TARGETS }}
- name: Log into registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
uses: docker/metadata-action@v4
with:
images: ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ env.DOCKER_METADATA_OUTPUT_TAGS }}
build-args: |
DOCKER_METADATA_OUTPUT_JSON
platforms: ${{ env.DOCKER_TARGETS }}
cache-from: type=gha
cache-to: type=gha,mode=max