fix(ci): don't hang forever waiting for migration job to complete

This commit is contained in:
2026-04-08 05:05:40 +00:00
parent 557e729ca9
commit 9a1a641e97
+24 -1
View File
@@ -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