Some checks failed
ci / tests (push) Has been cancelled
- Publish images on semantic version tags (vX.Y.Z) as :vX.Y.Z and :latest - Publish :stable image via workflow_run after successful Stable Tag workflow - Build stable image from exact commit marked as stable - Remove duplicate build steps and unify tag computation https://chatgpt.com/share/694b9758-58fc-800f-a586-8f3a341ece9d
68 lines
1.8 KiB
YAML
68 lines
1.8 KiB
YAML
name: publish-image
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- "v*.*.*"
|
|
|
|
workflow_run:
|
|
workflows: ["Stable Tag"] # MUST match stable-tag.yml -> name: Stable Tag
|
|
types: [completed]
|
|
|
|
jobs:
|
|
build-and-push:
|
|
if: |
|
|
(github.event_name == 'push') ||
|
|
(github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success')
|
|
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
# push: checks out the tag ref
|
|
# workflow_run: checks out the exact commit that the Stable Tag workflow ran on
|
|
ref: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.head_sha || github.ref }}
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v3
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Login to GHCR
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Compute tags
|
|
id: meta
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
IMAGE="ghcr.io/${{ github.repository }}"
|
|
|
|
if [ "${{ github.event_name }}" = "push" ]; then
|
|
TAG="${{ github.ref_name }}" # e.g. v1.1.0
|
|
echo "tags=$IMAGE:$TAG,$IMAGE:latest" >> "$GITHUB_OUTPUT"
|
|
else
|
|
echo "tags=$IMAGE:stable" >> "$GITHUB_OUTPUT"
|
|
fi
|
|
|
|
- name: Build and push
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
file: ./Dockerfile
|
|
push: true
|
|
platforms: linux/amd64,linux/arm64
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|