fix: Production workflow fixes
All checks were successful
Deploy to Staging / Build Images (push) Successful in 21s
Deploy to Staging / Deploy to Staging (push) Successful in 27s
Deploy to Staging / Verify Staging (push) Successful in 5s
Deploy to Staging / Notify Staging Ready (push) Successful in 5s
Deploy to Staging / Notify Staging Failure (push) Has been skipped
All checks were successful
Deploy to Staging / Build Images (push) Successful in 21s
Deploy to Staging / Deploy to Staging (push) Successful in 27s
Deploy to Staging / Verify Staging (push) Successful in 5s
Deploy to Staging / Notify Staging Ready (push) Successful in 5s
Deploy to Staging / Notify Staging Failure (push) Has been skipped
This commit is contained in:
@@ -139,6 +139,22 @@ jobs:
|
|||||||
chmod +x scripts/ci/health-check.sh
|
chmod +x scripts/ci/health-check.sh
|
||||||
./scripts/ci/health-check.sh $TARGET_STACK $HEALTH_CHECK_TIMEOUT
|
./scripts/ci/health-check.sh $TARGET_STACK $HEALTH_CHECK_TIMEOUT
|
||||||
|
|
||||||
|
- name: Start Traefik
|
||||||
|
run: |
|
||||||
|
cd "$DEPLOY_PATH"
|
||||||
|
docker compose -f $COMPOSE_FILE -f $COMPOSE_BLUE_GREEN up -d mvp-traefik
|
||||||
|
|
||||||
|
- name: Wait for Traefik
|
||||||
|
run: |
|
||||||
|
echo "Waiting for Traefik to be healthy..."
|
||||||
|
timeout 30 bash -c "until docker inspect --format='{{.State.Health.Status}}' mvp-traefik 2>/dev/null | grep -q healthy; do sleep 2; done" || {
|
||||||
|
echo "Traefik health check timed out, checking status..."
|
||||||
|
docker inspect --format='{{.State.Status}}' mvp-traefik
|
||||||
|
docker logs mvp-traefik --tail 20
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
echo "Traefik is healthy"
|
||||||
|
|
||||||
- name: Switch traffic
|
- name: Switch traffic
|
||||||
run: |
|
run: |
|
||||||
cd "$DEPLOY_PATH"
|
cd "$DEPLOY_PATH"
|
||||||
@@ -172,19 +188,43 @@ jobs:
|
|||||||
|
|
||||||
- name: External health check
|
- name: External health check
|
||||||
run: |
|
run: |
|
||||||
|
REQUIRED_FEATURES='["admin","auth","onboarding","vehicles","documents","fuel-logs","stations","maintenance","platform","notifications","user-profile","user-preferences","user-export"]'
|
||||||
|
|
||||||
for i in 1 2 3 4 5 6; do
|
for i in 1 2 3 4 5 6; do
|
||||||
if curl -sf https://motovaultpro.com/api/health > /dev/null 2>&1; then
|
RESPONSE=$(curl -sf https://motovaultpro.com/api/health 2>/dev/null) || {
|
||||||
echo "OK: Production external health check passed"
|
echo "Attempt $i/6: Connection failed, waiting 10s..."
|
||||||
exit 0
|
sleep 10
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check status is "healthy"
|
||||||
|
STATUS=$(echo "$RESPONSE" | jq -r '.status')
|
||||||
|
if [ "$STATUS" != "healthy" ]; then
|
||||||
|
echo "Attempt $i/6: Status is '$STATUS', not 'healthy'. Waiting 10s..."
|
||||||
|
sleep 10
|
||||||
|
continue
|
||||||
fi
|
fi
|
||||||
if [ $i -eq 6 ]; then
|
|
||||||
echo "ERROR: Production external health check failed after 6 attempts"
|
# Check all required features are present
|
||||||
exit 1
|
MISSING=$(echo "$RESPONSE" | jq -r --argjson required "$REQUIRED_FEATURES" '
|
||||||
|
$required - .features | if length > 0 then . else empty end | @json
|
||||||
|
')
|
||||||
|
|
||||||
|
if [ -n "$MISSING" ]; then
|
||||||
|
echo "Attempt $i/6: Missing features: $MISSING. Waiting 10s..."
|
||||||
|
sleep 10
|
||||||
|
continue
|
||||||
fi
|
fi
|
||||||
echo "Attempt $i/6: Waiting 10s..."
|
|
||||||
sleep 10
|
FEATURE_COUNT=$(echo "$RESPONSE" | jq '.features | length')
|
||||||
|
echo "OK: Production health check passed - status: healthy, features: $FEATURE_COUNT"
|
||||||
|
exit 0
|
||||||
done
|
done
|
||||||
|
|
||||||
|
echo "ERROR: Production health check failed after 6 attempts"
|
||||||
|
echo "Last response: $RESPONSE"
|
||||||
|
exit 1
|
||||||
|
|
||||||
- name: Verify container status
|
- name: Verify container status
|
||||||
run: |
|
run: |
|
||||||
for service in mvp-frontend-$TARGET_STACK mvp-backend-$TARGET_STACK; do
|
for service in mvp-frontend-$TARGET_STACK mvp-backend-$TARGET_STACK; do
|
||||||
|
|||||||
@@ -205,19 +205,43 @@ jobs:
|
|||||||
|
|
||||||
- name: Check external endpoint
|
- name: Check external endpoint
|
||||||
run: |
|
run: |
|
||||||
|
REQUIRED_FEATURES='["admin","auth","onboarding","vehicles","documents","fuel-logs","stations","maintenance","platform","notifications","user-profile","user-preferences","user-export"]'
|
||||||
|
|
||||||
for i in 1 2 3 4 5 6; do
|
for i in 1 2 3 4 5 6; do
|
||||||
if curl -sf https://staging.motovaultpro.com/api/health > /dev/null 2>&1; then
|
RESPONSE=$(curl -sf https://staging.motovaultpro.com/api/health 2>/dev/null) || {
|
||||||
echo "OK: Staging external health check passed"
|
echo "Attempt $i/6: Connection failed, waiting 10s..."
|
||||||
exit 0
|
sleep 10
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check status is "healthy"
|
||||||
|
STATUS=$(echo "$RESPONSE" | jq -r '.status')
|
||||||
|
if [ "$STATUS" != "healthy" ]; then
|
||||||
|
echo "Attempt $i/6: Status is '$STATUS', not 'healthy'. Waiting 10s..."
|
||||||
|
sleep 10
|
||||||
|
continue
|
||||||
fi
|
fi
|
||||||
if [ $i -eq 6 ]; then
|
|
||||||
echo "ERROR: Staging external health check failed after 6 attempts"
|
# Check all required features are present
|
||||||
exit 1
|
MISSING=$(echo "$RESPONSE" | jq -r --argjson required "$REQUIRED_FEATURES" '
|
||||||
|
$required - .features | if length > 0 then . else empty end | @json
|
||||||
|
')
|
||||||
|
|
||||||
|
if [ -n "$MISSING" ]; then
|
||||||
|
echo "Attempt $i/6: Missing features: $MISSING. Waiting 10s..."
|
||||||
|
sleep 10
|
||||||
|
continue
|
||||||
fi
|
fi
|
||||||
echo "Attempt $i/6: Waiting 10s..."
|
|
||||||
sleep 10
|
FEATURE_COUNT=$(echo "$RESPONSE" | jq '.features | length')
|
||||||
|
echo "OK: Staging health check passed - status: healthy, features: $FEATURE_COUNT"
|
||||||
|
exit 0
|
||||||
done
|
done
|
||||||
|
|
||||||
|
echo "ERROR: Staging health check failed after 6 attempts"
|
||||||
|
echo "Last response: $RESPONSE"
|
||||||
|
exit 1
|
||||||
|
|
||||||
# ============================================
|
# ============================================
|
||||||
# NOTIFY - Staging ready for production
|
# NOTIFY - Staging ready for production
|
||||||
# ============================================
|
# ============================================
|
||||||
|
|||||||
Reference in New Issue
Block a user