ci: fix container publish workflow to run on version tag pushes
Switch publish-containers workflow from workflow_run to direct v* tag triggers, remove obsolete workflow_run logic, simplify version detection via GITHUB_REF_NAME, and keep stable-tag detection aligned with the stable ref. https://chatgpt.com/share/693c836b-0b00-800f-9536-9e273abd0fb5
This commit is contained in:
25
.github/workflows/publish-containers.yml
vendored
25
.github/workflows/publish-containers.yml
vendored
@@ -1,13 +1,12 @@
|
|||||||
name: Publish container images (GHCR)
|
name: Publish container images (GHCR)
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_run:
|
push:
|
||||||
workflows: ["Mark stable commit"]
|
tags:
|
||||||
types: [completed]
|
- "v*"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
publish:
|
publish:
|
||||||
if: ${{ github.event.workflow_run.conclusion == 'success' }}
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
@@ -21,34 +20,28 @@ jobs:
|
|||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
fetch-tags: true
|
fetch-tags: true
|
||||||
|
|
||||||
- name: Checkout workflow_run commit
|
|
||||||
run: |
|
|
||||||
set -euo pipefail
|
|
||||||
git checkout -f "${{ github.event.workflow_run.head_sha }}"
|
|
||||||
|
|
||||||
- name: Compute version and stable flag
|
- name: Compute version and stable flag
|
||||||
id: info
|
id: info
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
SHA="$(git rev-parse HEAD)"
|
SHA="$(git rev-parse HEAD)"
|
||||||
V_TAG="$(git tag --points-at "${SHA}" --list 'v*' | sort -V | tail -n1)"
|
VERSION="${GITHUB_REF_NAME#v}"
|
||||||
[[ -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)"
|
STABLE_SHA="$(git rev-parse -q --verify refs/tags/stable^{commit} 2>/dev/null || true)"
|
||||||
IS_STABLE=false
|
IS_STABLE=false
|
||||||
[[ "$STABLE_SHA" == "$SHA" ]] && IS_STABLE=true
|
[[ -n "${STABLE_SHA}" && "${STABLE_SHA}" == "${SHA}" ]] && IS_STABLE=true
|
||||||
|
|
||||||
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
|
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
|
||||||
echo "is_stable=${IS_STABLE}" >> "$GITHUB_OUTPUT"
|
echo "is_stable=${IS_STABLE}" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
- uses: docker/setup-buildx-action@v3
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
with:
|
with:
|
||||||
use: true
|
use: true
|
||||||
|
|
||||||
- uses: docker/login-action@v3
|
- name: Login to GHCR
|
||||||
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
|
|||||||
Reference in New Issue
Block a user