From 8458149103ad53bd91ffbeb1ba8790d0f68eb804 Mon Sep 17 00:00:00 2001 From: dhkatz Date: Thu, 19 Nov 2026 02:15:16 -0800 Subject: [PATCH] CI: only main's newest commit moves latest-main --- .gitea/workflows/ci.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 002ce61..014f53e 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -55,7 +55,11 @@ jobs: DOCKERFILE: ${{ matrix.dockerfile }} run: | case "$GITHUB_REF" in - refs/heads/main) version="main-${GITHUB_SHA::12}"; tags="latest-main $version" ;; + refs/heads/main) + version="main-${GITHUB_SHA::12}"; tags="$version" + # Merges close together can finish out of order: only main's newest commit moves latest-main (staging). + if [ "$(git ls-remote origin refs/heads/main | cut -f1)" = "$GITHUB_SHA" ]; then tags="latest-main $tags" + else echo "main has moved on since this commit: :$version only, latest-main stays"; fi ;; refs/tags/v*) version="${GITHUB_REF#refs/tags/v}" [[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || { echo "Not a vX.Y.Z tag: no image"; exit 0; } -- 2.54.0