From c85aaaadf41b895ab53e95ae8966334e4f5a3471 Mon Sep 17 00:00:00 2001 From: hcornet Date: Thu, 10 Sep 2026 14:28:36 +0200 Subject: [PATCH] Reprise du rechargement, version sans prefixe v --- .gitea/workflows/build.yaml | 2 +- docker/catalog-sync.sh | 24 ++++++++++++++++++++---- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml index 22317a2..1be8534 100644 --- a/.gitea/workflows/build.yaml +++ b/.gitea/workflows/build.yaml @@ -83,7 +83,7 @@ jobs: tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} build-args: | - ENCLUME_VERSION=${{ gitea.ref_name }} + ENCLUME_VERSION=${{ steps.meta.outputs.version }} ENCLUME_COMMIT=${{ gitea.sha }} BUILD_DATE=${{ steps.meta.outputs.created }} # Les attestations de provenance de Buildx creent des manifestes diff --git a/docker/catalog-sync.sh b/docker/catalog-sync.sh index 99a5fe6..9048b48 100644 --- a/docker/catalog-sync.sh +++ b/docker/catalog-sync.sh @@ -20,6 +20,23 @@ if [ -z "${CATALOG_REPO:-}" ]; then fi TRAVAIL=/tmp/depot +TEMOIN=/tmp/derniere-revision-confirmee + +# Previent l'application, et retient si elle a repondu. Tant que la reponse +# n'est pas obtenue, on retente au cycle suivant : au demarrage, catalog-sync +# publie souvent avant que web n'ecoute, et sans cette reprise le site +# resterait sur le catalogue charge a son lancement. +prevenir_application() { + revision="$1" + [ -n "${RELOAD_URL:-}" ] || return 0 + [ "$(cat "$TEMOIN" 2>/dev/null)" = "$revision" ] && return 0 + if curl -fsS --max-time 10 -X POST "$RELOAD_URL" >/dev/null 2>&1; then + echo "$revision" > "$TEMOIN" + echo "catalog-sync : application rechargee ($revision)" + else + echo "catalog-sync : application injoignable, nouvelle tentative au prochain cycle" >&2 + fi +} sync_une_fois() { if [ -d "$TRAVAIL/.git" ]; then @@ -40,7 +57,8 @@ sync_une_fois() { CIBLE="$CATALOG_DEST/rev-$REVISION" if [ -L "$CATALOG_DEST/actuel" ] && [ "$(readlink "$CATALOG_DEST/actuel")" = "$CIBLE" ]; then - return 0 # deja publie, rien a faire + prevenir_application "$REVISION" # publie, mais l'application l'ignore peut-etre encore + return 0 fi rm -rf "$CIBLE.partiel" "$CIBLE" @@ -57,9 +75,7 @@ sync_une_fois() { done echo "catalog-sync : catalogue publie ($REVISION)" - if [ -n "${RELOAD_URL:-}" ]; then - curl -fsS -X POST "$RELOAD_URL" >/dev/null 2>&1 || echo "catalog-sync : rechargement non confirme" - fi + prevenir_application "$REVISION" } while true; do