Some checks failed
Mark stable commit / test-unit (push) Has been cancelled
Mark stable commit / test-integration (push) Has been cancelled
Mark stable commit / test-env-virtual (push) Has been cancelled
Mark stable commit / test-env-nix (push) Has been cancelled
Mark stable commit / test-e2e (push) Has been cancelled
Mark stable commit / test-virgin-user (push) Has been cancelled
Mark stable commit / test-virgin-root (push) Has been cancelled
Mark stable commit / mark-stable (push) Has been cancelled
Trigger container publishing via workflow_run on "Mark stable commit", gate on success, checkout the workflow_run head SHA, force-refresh tags, and derive version from the v* tag pointing at the tested commit to correctly detect and publish stable images. https://chatgpt.com/share/693c836b-0b00-800f-9536-9e273abd0fb5
67 lines
1.9 KiB
YAML
67 lines
1.9 KiB
YAML
name: Publish container images (GHCR)
|
|
|
|
on:
|
|
workflow_run:
|
|
workflows: ["Mark stable commit"]
|
|
types: [completed]
|
|
|
|
jobs:
|
|
publish:
|
|
if: ${{ github.event.workflow_run.conclusion == 'success' }}
|
|
runs-on: ubuntu-latest
|
|
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
|
|
steps:
|
|
- name: Checkout repository (with tags)
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
fetch-tags: true
|
|
|
|
- name: Checkout workflow_run commit and refresh tags
|
|
run: |
|
|
set -euo pipefail
|
|
git checkout -f "${{ github.event.workflow_run.head_sha }}"
|
|
git fetch --tags --force
|
|
git tag --list 'stable' 'v*' --sort=version:refname | tail -n 20
|
|
|
|
- name: Compute version and stable flag
|
|
id: info
|
|
run: |
|
|
set -euo pipefail
|
|
SHA="$(git rev-parse HEAD)"
|
|
|
|
V_TAG="$(git tag --points-at "${SHA}" --list 'v*' | sort -V | tail -n1)"
|
|
[[ -n "$V_TAG" ]] || { echo "No version tag found"; exit 1; }
|
|
VERSION="${V_TAG#v}"
|
|
|
|
STABLE_SHA="$(git rev-parse -q --verify refs/tags/stable^{commit} 2>/dev/null || true)"
|
|
IS_STABLE=false
|
|
[[ -n "${STABLE_SHA}" && "${STABLE_SHA}" == "${SHA}" ]] && IS_STABLE=true
|
|
|
|
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
|
|
echo "is_stable=${IS_STABLE}" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
with:
|
|
use: true
|
|
|
|
- name: Login to GHCR
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Publish all images
|
|
run: |
|
|
set -euo pipefail
|
|
OWNER="${{ github.repository_owner }}" \
|
|
VERSION="${{ steps.info.outputs.version }}" \
|
|
IS_STABLE="${{ steps.info.outputs.is_stable }}" \
|
|
bash scripts/build/publish.sh
|