From 7e957d6fb48a63b4a0336f0c4e26857df99b181a Mon Sep 17 00:00:00 2001 From: Marc Mintel Date: Fri, 27 Feb 2026 23:37:47 +0100 Subject: [PATCH] fix(deploy): add retry loop to payload migration curl to handle slow postgres startups --- .gitea/workflows/deploy.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index a116cc7..bf4d556 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -344,7 +344,13 @@ jobs: ssh root@alpha.mintel.me "cd $SITE_DIR && docker compose -p '${{ needs.prepare.outputs.project_name }}' --env-file '$ENV_FILE' up -d --remove-orphans" # Apply Payload Migrations using the target app container's programmatic endpoint - ssh root@alpha.mintel.me "cd $SITE_DIR && echo '→ Running Payload Migrations...' && docker compose -p '${{ needs.prepare.outputs.project_name }}' --env-file '$ENV_FILE' exec -T mb-grid-app sh -c 'curl -s -f -X POST -H \"Authorization: Bearer \$PAYLOAD_SECRET\" http://localhost:3000/api/payload/migrate' || { echo 'Migration failed!'; exit 1; }" + ssh root@alpha.mintel.me "cd $SITE_DIR && echo '→ Waiting for DB and Running Payload Migrations...' && \ + for i in {1..5}; do \ + echo \"Attempt \$i...\"; \ + docker compose -p '${{ needs.prepare.outputs.project_name }}' --env-file '$ENV_FILE' exec -T mb-grid-app sh -c 'curl -s -f -X POST -H \"Authorization: Bearer \$PAYLOAD_SECRET\" http://localhost:3000/api/payload/migrate \ + || { echo \"HTTP error or DB not ready.\"; exit 1; }' && { echo '✅ Migrations successful!'; break; } \ + || { if [ \$i -eq 5 ]; then echo '❌ Migration failed after 5 attempts!'; exit 1; else echo '⏳ Retrying in 5s...'; sleep 5; fi; }; \ + done" ssh root@alpha.mintel.me "docker system prune -f --filter 'until=24h'"