From ad7ec2ca2b94c2371f69d1b94dd9faab7f489eb5 Mon Sep 17 00:00:00 2001 From: enlineawork Date: Wed, 9 Sep 2026 11:28:53 -0300 Subject: [PATCH] fix(deploy): wait for exact candidate health version --- scripts/deploy-github.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/deploy-github.sh b/scripts/deploy-github.sh index 77d5d57..9a31dc0 100644 --- a/scripts/deploy-github.sh +++ b/scripts/deploy-github.sh @@ -247,16 +247,22 @@ echo "========== HEALTH ==========" HEALTH_OK=0 for _ in $(seq 1 60); do if curl -fsS --max-time 5 http://127.0.0.1:3101/api/v3/health > "$BACKUP/health.json" 2>/dev/null; then - if grep -F '"status":"ok"' "$BACKUP/health.json" >/dev/null; then + if grep -Fq '"status":"ok"' "$BACKUP/health.json" \ + && grep -Fq "\"version\":\"$EXPECTED_API_VERSION\"" "$BACKUP/health.json" \ + && grep -Fq '"database":"ok"' "$BACKUP/health.json"; then HEALTH_OK=1 break fi + + CURRENT_API_VERSION="$(node -e 'try { const h = JSON.parse(require("fs").readFileSync(process.argv[1], "utf8")); process.stdout.write(String(h.version || "unknown")); } catch { process.stdout.write("invalid"); }' "$BACKUP/health.json")" + echo "API respondió pero aún no es la candidata (actual=$CURRENT_API_VERSION, esperada=$EXPECTED_API_VERSION). Reintentando..." fi sleep 2 done if [ "$HEALTH_OK" -ne 1 ]; then - echo "ERROR: API no pasó healthcheck." + echo "ERROR: API candidata no pasó healthcheck/version/database dentro del plazo." + [ ! -f "$BACKUP/health.json" ] || cat "$BACKUP/health.json" docker compose logs --tail=180 api false fi