From d0f7e4d8c3572dc17f3a9f3005a1eaf682d430e5 Mon Sep 17 00:00:00 2001 From: dhkatz Date: Thu, 19 Nov 2026 10:18:22 +0000 Subject: [PATCH] ci: only main's newest commit moves latest-main (#24) Two merges close together can build out of order: on 2026-11-19, #22's image job finished two minutes after #23's and moved `:latest-main` back to #22's build, so staging ran without the OpenID provider. Now a main push tags `:main-` always, and `:latest-main` only if its commit is still main's newest (`git ls-remote origin refs/heads/main`). Whichever finishes last, `:latest-main` ends on the newest commit. Tags (`vX.Y.Z`) are unchanged. t5de-catalog and t5de-site have the same line, and need the same fix. Two merges close together can build out of order: on 2026-11-19, #22's image job finished two minutes after #23's and moved `:latest-main` back to #22's build, so staging ran without the OpenID provider. Now a main push tags `:main-` always, and `:latest-main` only if its commit is still main's newest (`git ls-remote origin refs/heads/main`). Whichever finishes last, `:latest-main` ends on the newest commit. Tags (`vX.Y.Z`) are unchanged. t5de-catalog and t5de-site have the same line, and need the same fix. Co-authored-by: dhkatz --- .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; }