Added docker build and publish workflow

This commit is contained in:
2026-03-30 22:23:57 +02:00
parent bdf7d4f468
commit b6746d2c0d
+114
View File
@@ -0,0 +1,114 @@
name: Build and Publish Multi-Arch Docker Image
on:
release:
types: [published]
env:
DOCKER_IMAGE: ${{ secrets.DOCKERHUB_USERNAME }}/quay
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
strategy:
fail-fast: false
matrix:
platform:
- linux/amd64
- linux/arm64
runs-on: ${{ matrix.platform == 'linux/amd64' && 'ubuntu-latest' || matrix.platform == 'linux/arm64' && 'ubuntu-24.04-arm' }}
name: Build Docker image for ${{ matrix.platform }}
steps:
- name: Set PLATFORM_PAIR
id: prepare
run: |
platform=${{ matrix.platform }}
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
platforms: ${{ matrix.platform }}
- name: Build and push image
id: build
uses: docker/build-push-action@v6
env:
DOCKER_BUILDKIT: 1
with:
context: .
push: true
platforms: ${{ matrix.platform }}
tags: |
${{ env.DOCKER_IMAGE }}:${{ github.ref_name }}-${{ env.PLATFORM_PAIR }}
${{ env.DOCKER_IMAGE }}:latest-${{ env.PLATFORM_PAIR }}
outputs: type=registry
cache-from: type=gha,scope=${{ github.repository }}-${{ github.ref_name }}-${{ env.PLATFORM_PAIR }}
cache-to: type=gha,scope=${{ github.repository }}-${{ github.ref_name }}-${{ env.PLATFORM_PAIR }}
- name: Export digest
run: |
mkdir -p /tmp/digests
echo "${{ steps.build.outputs.digest }}" > "/tmp/digests/${{ env.PLATFORM_PAIR }}"
- name: Upload digest
uses: actions/upload-artifact@v6
with:
name: digests-${{ env.PLATFORM_PAIR }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
merge:
name: Create Multi-Arch Manifest
runs-on: ubuntu-latest
needs: build
steps:
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Download digests
uses: actions/download-artifact@v7
with:
path: /tmp/digests
pattern: digests-*
merge-multiple: true
- name: Create multi-arch manifest
run: |
refs=()
for digest_file in /tmp/digests/*; do
digest=$(cat "$digest_file")
refs+=("${{ env.DOCKER_IMAGE }}@${digest}")
done
docker buildx imagetools create \
-t ${{ env.DOCKER_IMAGE }}:${{ github.ref_name }} \
-t ${{ env.DOCKER_IMAGE }}:latest \
"${refs[@]}"
- name: Inspect manifest
run: |
docker buildx imagetools inspect ${{ env.DOCKER_IMAGE }}:${{ github.ref_name }}