From 9a1a641e972bf65c3c0f252fd35653c0536d3dde Mon Sep 17 00:00:00 2001 From: Jackson Roberts Date: Wed, 8 Apr 2026 05:05:40 +0000 Subject: [PATCH] fix(ci): don't hang forever waiting for migration job to complete --- .github/workflows/deploy.yaml | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 40274aa..1b31847 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -305,7 +305,30 @@ jobs: - name: Wait for migration to complete run: | TAG=${{ github.event.release.tag_name }} - kubectl wait --for=condition=complete --timeout=120s -n optima job/prisma-migrate-${TAG} + JOB="job/prisma-migrate-${TAG}" + + # Wait for either success or failure — whichever comes first. + kubectl wait --for=condition=complete --timeout=180s -n optima "$JOB" & + WAIT_COMPLETE=$! + kubectl wait --for=condition=failed --timeout=180s -n optima "$JOB" & + WAIT_FAILED=$! + + # wait -n returns when the first background job exits + wait -n $WAIT_COMPLETE $WAIT_FAILED + FIRST_EXIT=$? + + # Print logs regardless of outcome so failures are diagnosable + echo "--- Migration pod logs ---" + kubectl logs -n optima -l app=prisma-migrate --tail=200 || true + + # Determine outcome by checking the job's actual conditions + if kubectl get -n optima "$JOB" -o jsonpath='{.status.conditions[?(@.type=="Complete")].status}' | grep -q "True"; then + echo "Migration completed successfully." + exit 0 + else + echo "Migration FAILED." + exit 1 + fi deploy-api: name: Deploy - API