Files
matomo-bootstrap/.github/workflows/publish-image.yml
Kevin Veen-Birkenbach bac453c435
Some checks failed
CI / test (push) Has been cancelled
ci: add GHCR publish workflow gated by tests
- build & push image on tag
- publish :latest only for semver tags
- multi-arch (amd64, arm64)

https://chatgpt.com/share/694ae4b0-ca28-800f-863c-0916a2f62a43
2025-12-23 19:51:10 +01:00

75 lines
1.8 KiB
YAML

name: publish-image
on:
push:
tags:
- "*"
jobs:
tests:
uses: ./.github/workflows/reusable-test.yml
build-and-push:
needs: tests
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Extract tag
id: meta
run: |
echo "tag=${GITHUB_REF_NAME}" >> "$GITHUB_OUTPUT"
- name: Check semver tag
id: semver
run: |
if [[ "${GITHUB_REF_NAME}" =~ ^v?[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "is_semver=true" >> "$GITHUB_OUTPUT"
else
echo "is_semver=false" >> "$GITHUB_OUTPUT"
fi
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push (tag)
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: true
platforms: linux/amd64,linux/arm64
tags: |
ghcr.io/${{ github.repository }}:${{ steps.meta.outputs.tag }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Build and push (latest)
if: steps.semver.outputs.is_semver == 'true'
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: true
platforms: linux/amd64,linux/arm64
tags: |
ghcr.io/${{ github.repository }}:latest
cache-from: type=gha
cache-to: type=gha,mode=max