diff --git a/deploy.sh b/deploy.sh index 777c331..78e2531 100755 --- a/deploy.sh +++ b/deploy.sh @@ -173,20 +173,25 @@ curl -sk -X POST -H "Authorization: Bearer ${COOLIFY_ACCESS_TOKEN}" \ # ── Step 8: Wait for deployment ────────────────────────────────────── echo "[deploy] Waiting for deployment..." +sleep 15 +FAIL_COUNT=0 for i in $(seq 1 30); do sleep 10 STATUS=$(curl -sk -H "Authorization: Bearer ${COOLIFY_ACCESS_TOKEN}" \ "${COOLIFY_API}/applications/${APP_UUID}" | python3 -c "import sys,json; print(json.load(sys.stdin).get('status','unknown'))" 2>/dev/null) echo "[deploy] Status: ${STATUS} (attempt ${i}/30)" - if [ "${STATUS}" = "running" ]; then + if [[ "${STATUS}" == running* ]]; then + echo "[deploy] App is running!" break fi if [[ "${STATUS}" == exited* ]] || [ "${STATUS}" = "error" ]; then - echo "[deploy] Deployment failed with status: ${STATUS}" - # Get logs - curl -sk -H "Authorization: Bearer ${COOLIFY_ACCESS_TOKEN}" \ - "${COOLIFY_API}/applications/${APP_UUID}/logs" 2>/dev/null | tail -20 - exit 1 + FAIL_COUNT=$((FAIL_COUNT + 1)) + if [ "${FAIL_COUNT}" -ge 3 ]; then + echo "[deploy] Deployment failed with status: ${STATUS}" + curl -sk -H "Authorization: Bearer ${COOLIFY_ACCESS_TOKEN}" \ + "${COOLIFY_API}/applications/${APP_UUID}/logs" 2>/dev/null | tail -20 + exit 1 + fi fi done