Skip to content

Docker Publish

Docker Publish #71

name: Docker Publish
on:
workflow_dispatch:
schedule:
- cron: '0 21 * * 6'
push:
branches: [ "main" ]
env:
REGISTRY: docker.io
DOCKER_USERNAME: manuelklaer
DOCKER_REPO: cups-canon
PLATFORMS: linux/amd64,linux/arm64,linux/386
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
# Set up Docker QEMU to be able to build
# multi-platform images
- name: Docker Setup QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: ${{ env.PLATFORMS }}
# Set up BuildKit Docker container builder to be able to build
# multi-platform images and export cache
# https://github.com/docker/setup-buildx-action
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# Login against a Docker registry
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ env.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
# Build and push Docker image with Buildx
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v6
with:
context: .
platforms: ${{ env.PLATFORMS }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ env.DOCKER_USERNAME }}/${{ env.DOCKER_REPO }}:latest
cache-from: type=gha
cache-to: type=gha,mode=max