push docker images to quay.io as well (#346)

This PR adjusts the GH Workflows to also push the container images to
quay.io
This commit is contained in:
Maximilian Dorninger
2026-01-04 22:31:58 +01:00
committed by GitHub
parent 1f12a7cc3b
commit 7e334ffbb1
2 changed files with 242 additions and 192 deletions

View File

@@ -60,21 +60,22 @@ jobs:
run: npm run lint
working-directory: ./web
build:
build-and-push:
needs: [lint-frontend, lint-backend]
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- platform: linux/arm64
runner: ubuntu-24.04-arm
- platform: linux/amd64
- arch: amd64
runner: ubuntu-24.04
- arch: arm64
runner: ubuntu-24.04-arm
runs-on: ${{ matrix.runner }}
permissions:
contents: read
packages: write
packages: write
env:
QUAY_ORG: ${{ secrets.QUAY_ORG }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
@@ -83,12 +84,11 @@ jobs:
id: repo_name
run: echo "name=$(echo '${{ github.event.repository.name }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
- name: Prepare platform slug
id: platform_slug
run: echo "slug=${{ matrix.platform }}" | tr '/' '-' >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
install: true
driver-opts: image=moby/buildkit:rootless
- name: Log in to GitHub Container Registry
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
@@ -98,80 +98,13 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract version
id: version
run: |
if [[ "${{ github.event_name }}" == "release" ]]; then
VERSION="${{ github.event.release.tag_name }}"
elif [[ "${{ github.ref_type }}" == "tag" ]]; then
VERSION="${{ github.ref_name }}"
else
DATE_STAMP=$(date -u +'%Y.%m.%d')
VERSION="dev-${DATE_STAMP}-${{ github.run_number }}"
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Extract metadata (labels only)
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository_owner }}/${{ steps.repo_name.outputs.name }}/mediamanager
- name: Build and push by digest
id: build
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
platforms: ${{ matrix.platform }}
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=ghcr.io/${{ github.repository_owner }}/${{ steps.repo_name.outputs.name }}/mediamanager,push-by-digest=true,name-canonical=true,push=${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }}
build-args: |
VERSION=${{ steps.version.outputs.version }}
BASE_PATH=
- name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-backend-${{ strategy.job-index }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
merge:
needs: build
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
steps:
- name: Download digests
uses: actions/download-artifact@v4
with:
pattern: digests-backend-*
path: /tmp/digests
merge-multiple: true
- name: Set repository name to lowercase
id: repo_name
run: echo "name=$(echo '${{ github.event.repository.name }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
- name: Log in to Quay
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
- name: Extract version
id: version
@@ -188,11 +121,94 @@ jobs:
VERSION_NO_V=${VERSION#v}
echo "version_no_v=$VERSION_NO_V" >> $GITHUB_OUTPUT
- name: Extract metadata (tags)
- name: Extract metadata (tags + labels)
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository_owner }}/${{ steps.repo_name.outputs.name }}/mediamanager
images: |
ghcr.io/${{ github.repository_owner }}/${{ steps.repo_name.outputs.name }}/mediamanager
quay.io/${{ env.QUAY_ORG }}/mediamanager
tags: |
type=raw,value=latest,enable=${{ github.event_name == 'release' }}
type=raw,value=${{ steps.version.outputs.version }},enable=${{ github.event_name != 'release' }}
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
flavor: |
suffix=-${{ matrix.arch }},onlatest=true
- name: Build and push arch image
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
platforms: linux/${{ matrix.arch }}
push: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
VERSION=${{ steps.version.outputs.version }}
BASE_PATH=
publish-manifests:
needs: build-and-push
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-24.04
permissions:
contents: read
packages: write
env:
QUAY_ORG: ${{ secrets.QUAY_ORG }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set repository name to lowercase
id: repo_name
run: echo "name=$(echo '${{ github.event.repository.name }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Log in to Quay
uses: docker/login-action@v3
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
- name: Extract version
id: version
run: |
if [[ "${{ github.event_name }}" == "release" ]]; then
VERSION="${{ github.event.release.tag_name }}"
elif [[ "${{ github.ref_type }}" == "tag" ]]; then
VERSION="${{ github.ref_name }}"
else
DATE_STAMP=$(date -u +'%Y.%m.%d')
VERSION="dev-${DATE_STAMP}-${{ github.run_number }}"
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
VERSION_NO_V=${VERSION#v}
echo "version_no_v=$VERSION_NO_V" >> $GITHUB_OUTPUT
- name: Extract metadata (tags + labels)
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ github.repository_owner }}/${{ steps.repo_name.outputs.name }}/mediamanager
quay.io/${{ env.QUAY_ORG }}/mediamanager
tags: |
type=raw,value=latest,enable=${{ github.event_name == 'release' }}
type=raw,value=${{ steps.version.outputs.version }},enable=${{ github.event_name != 'release' }}
@@ -203,12 +219,21 @@ jobs:
type=semver,pattern={{major}}
type=sha
- name: Create manifest list and push
working-directory: /tmp/digests
- name: Create and push multi-arch manifests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf 'ghcr.io/${{ github.repository_owner }}/${{ steps.repo_name.outputs.name }}/mediamanager@sha256:%s ' *)
set -euo pipefail
mapfile -t TAGS <<< "${{ steps.meta.outputs.tags }}"
for TAG in "${TAGS[@]}"; do
docker buildx imagetools create \
--tag "${TAG}" \
"${TAG}-amd64" \
"${TAG}-arm64"
done
- name: Inspect image
- name: Inspect image (GHCR)
run: |
docker buildx imagetools inspect ghcr.io/${{ github.repository_owner }}/${{ steps.repo_name.outputs.name }}/mediamanager:${{ steps.version.outputs.version_no_v }}
docker buildx imagetools inspect ghcr.io/${{ github.repository_owner }}/${{ steps.repo_name.outputs.name }}/mediamanager:${{ steps.version.outputs.version_no_v }}
- name: Inspect image (Quay)
run: |
docker buildx imagetools inspect quay.io/${{ env.QUAY_ORG }}/mediamanager:${{ steps.version.outputs.version_no_v }}

View File

@@ -12,34 +12,35 @@ on:
- 'metadata_relay/**'
- '.github/workflows/build-push-metadata_relay.yml'
release:
types: [ published ]
types: [ published ]
workflow_dispatch:
jobs:
lint-code:
name: Lint Python Code
name: Lint Python Code
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/ruff-action@v3
- uses: astral-sh/ruff-action@v3
with:
src: "./metadata_relay"
build:
build-and-push:
needs: lint-code
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- platform: linux/arm64
runner: ubuntu-24.04-arm
- platform: linux/amd64
- arch: amd64
runner: ubuntu-24.04
- arch: arm64
runner: ubuntu-24.04-arm
runs-on: ${{ matrix.runner }}
permissions:
contents: read
packages: write
packages: write
env:
QUAY_ORG: ${{ secrets.QUAY_ORG }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
@@ -48,94 +49,27 @@ jobs:
id: repo_name
run: echo "name=$(echo '${{ github.event.repository.name }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
- name: Prepare platform slug
id: platform_slug
run: echo "slug=${{ matrix.platform }}" | tr '/' '-' >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
install: true
driver-opts: image=moby/buildkit:rootless
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Log in to Quay
uses: docker/login-action@v3
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract version
id: version
run: |
if [[ "${{ github.event_name }}" == "release" ]]; then
VERSION="${{ github.event.release.tag_name }}"
elif [[ "${{ github.ref_type }}" == "tag" ]]; then
VERSION="${{ github.ref_name }}"
else
DATE_STAMP=$(date -u +'%Y.%m.%d')
VERSION="dev-${DATE_STAMP}-${{ github.run_number }}"
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Extract metadata (labels only)
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository_owner }}/${{ steps.repo_name.outputs.name }}/metadata_relay
- name: Build and push by digest
id: build
uses: docker/build-push-action@v6
with:
context: ./metadata_relay
file: ./metadata_relay/Dockerfile
platforms: ${{ matrix.platform }}
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=ghcr.io/${{ github.repository_owner }}/${{ steps.repo_name.outputs.name }}/metadata_relay,push-by-digest=true,name-canonical=true,push=${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }}
build-args: |
VERSION=${{ steps.version.outputs.version }}
- name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-relay-${{ strategy.job-index }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
merge:
needs: build
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
steps:
- name: Download digests
uses: actions/download-artifact@v4
with:
pattern: digests-relay-*
path: /tmp/digests
merge-multiple: true
- name: Set repository name to lowercase
id: repo_name
run: echo "name=$(echo '${{ github.event.repository.name }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
- name: Extract version
id: version
@@ -152,11 +86,93 @@ jobs:
VERSION_NO_V=${VERSION#v}
echo "version_no_v=$VERSION_NO_V" >> $GITHUB_OUTPUT
- name: Extract metadata (tags)
- name: Extract metadata (tags + labels)
id: meta
uses: docker/metadata-action@v5
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository_owner }}/${{ steps.repo_name.outputs.name }}/metadata_relay
images: |
ghcr.io/${{ github.repository_owner }}/${{ steps.repo_name.outputs.name }}/metadata_relay
quay.io/${{ env.QUAY_ORG }}/metadata_relay
tags: |
type=raw,value=latest,enable=${{ github.event_name == 'release' }}
type=raw,value=${{ steps.version.outputs.version }},enable=${{ github.event_name != 'release' }}
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
flavor: |
suffix=-${{ matrix.arch }},onlatest=true
- name: Build and push arch image
uses: docker/build-push-action@v6
with:
context: ./metadata_relay
file: ./metadata_relay/Dockerfile
platforms: linux/${{ matrix.arch }}
push: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
VERSION=${{ steps.version.outputs.version }}
publish-manifests:
needs: build-and-push
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-24.04
permissions:
contents: read
packages: write
env:
QUAY_ORG: ${{ secrets.QUAY_ORG }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set repository name to lowercase
id: repo_name
run: echo "name=$(echo '${{ github.event.repository.name }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Log in to Quay
uses: docker/login-action@v3
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
- name: Extract version
id: version
run: |
if [[ "${{ github.event_name }}" == "release" ]]; then
VERSION="${{ github.event.release.tag_name }}"
elif [[ "${{ github.ref_type }}" == "tag" ]]; then
VERSION="${{ github.ref_name }}"
else
DATE_STAMP=$(date -u +'%Y.%m.%d')
VERSION="dev-${DATE_STAMP}-${{ github.run_number }}"
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
VERSION_NO_V=${VERSION#v}
echo "version_no_v=$VERSION_NO_V" >> $GITHUB_OUTPUT
- name: Extract metadata (tags + labels)
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ github.repository_owner }}/${{ steps.repo_name.outputs.name }}/metadata_relay
quay.io/${{ env.QUAY_ORG }}/metadata_relay
tags: |
type=raw,value=latest,enable=${{ github.event_name == 'release' }}
type=raw,value=${{ steps.version.outputs.version }},enable=${{ github.event_name != 'release' }}
@@ -167,12 +183,21 @@ jobs:
type=semver,pattern={{major}}
type=sha
- name: Create manifest list and push
working-directory: /tmp/digests
- name: Create and push multi-arch manifests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf 'ghcr.io/${{ github.repository_owner }}/${{ steps.repo_name.outputs.name }}/metadata_relay@sha256:%s ' *)
set -euo pipefail
mapfile -t TAGS <<< "${{ steps.meta.outputs.tags }}"
for TAG in "${TAGS[@]}"; do
docker buildx imagetools create \
--tag "${TAG}" \
"${TAG}-amd64" \
"${TAG}-arm64"
done
- name: Inspect image
- name: Inspect image (GHCR)
run: |
docker buildx imagetools inspect ghcr.io/${{ github.repository_owner }}/${{ steps.repo_name.outputs.name }}/metadata_relay:${{ steps.version.outputs.version_no_v }}
docker buildx imagetools inspect ghcr.io/${{ github.repository_owner }}/${{ steps.repo_name.outputs.name }}/metadata_relay:${{ steps.version.outputs.version_no_v }}
- name: Inspect image (Quay)
run: |
docker buildx imagetools inspect quay.io/${{ env.QUAY_ORG }}/metadata_relay:${{ steps.version.outputs.version_no_v }}