@@ -19,16 +19,17 @@ jobs:
1919 - name : Check registry health
2020 id : registry
2121 run : |
22+ # Use a temp file to isolate the HTTP code from error output
2223 HTTP_CODE=$(curl -sS -o /tmp/health-response -w '%{http_code}' \
23- --max-time 15 --retry 2 --retry-delay 5 \
24- 'https://registry.stacksjs.com/health' 2>/dev/null) || HTTP_CODE="000"
24+ --max-time 15 \
25+ 'https://registry.stacksjs.com/health' 2>/dev/null) || true
26+ # Extract only the last 3 chars (the HTTP code) in case of any prefix noise
27+ HTTP_CODE="${HTTP_CODE: -3}"
2528 echo "http_code=$HTTP_CODE" >> "$GITHUB_OUTPUT"
2629 if [ "$HTTP_CODE" = "200" ]; then
2730 echo "status=healthy" >> "$GITHUB_OUTPUT"
2831 else
29- BODY=$(cat /tmp/health-response 2>/dev/null | head -c 200 || echo "no response")
3032 echo "status=unhealthy" >> "$GITHUB_OUTPUT"
31- echo "body=$BODY" >> "$GITHUB_OUTPUT"
3233 fi
3334
3435 - name : Check S3 bucket accessibility
3839 AWS_SECRET_ACCESS_KEY : ${{ secrets.AWS_SECRET_ACCESS_KEY }}
3940 AWS_REGION : us-east-1
4041 run : |
41- if aws s3 ls s3://pantry-registry --max-items 1 >/dev/null 2>&1 ; then
42+ if aws s3api head-bucket --bucket pantry-registry 2 >/dev/null; then
4243 echo "status=accessible" >> "$GITHUB_OUTPUT"
4344 else
4445 echo "status=inaccessible" >> "$GITHUB_OUTPUT"
@@ -73,27 +74,31 @@ jobs:
7374 # Check update-pantry — should run every 20min, alert if >2h stale
7475 LAST_PANTRY=$(gh api \
7576 "repos/${{ github.repository }}/actions/workflows/update-pantry.yml/runs?status=success&per_page=1" \
76- --jq '.workflow_runs[0].updated_at' 2>/dev/null || echo "")
77- if [ -n "$LAST_PANTRY" ]; then
78- PANTRY_TS=$(date -u -d "$LAST_PANTRY" +%s 2>/dev/null || echo "0")
79- PANTRY_AGE=$(( (NOW - PANTRY_TS) / 3600 ))
80- if [ "$PANTRY_AGE" -gt 2 ]; then
81- STALE_ITEMS="update-pantry (${PANTRY_AGE}h ago)"
77+ --jq '.workflow_runs[0].updated_at // empty' 2>/dev/null || echo "")
78+ if [ -n "$LAST_PANTRY" ] && [ "$LAST_PANTRY" != "null" ]; then
79+ PANTRY_TS=$(date -u -d "$LAST_PANTRY" +%s 2>/dev/null || echo "")
80+ if [ -n "$PANTRY_TS" ] && [ "$PANTRY_TS" -gt 0 ] 2>/dev/null; then
81+ PANTRY_AGE=$(( (NOW - PANTRY_TS) / 3600 ))
82+ if [ "$PANTRY_AGE" -gt 2 ]; then
83+ STALE_ITEMS="update-pantry (${PANTRY_AGE}h ago)"
84+ fi
8285 fi
8386 fi
8487
8588 # Check sync-binaries — runs every 6h, alert if >12h stale
8689 LAST_SYNC=$(gh api \
8790 "repos/${{ github.repository }}/actions/workflows/sync-binaries.yml/runs?status=success&per_page=1" \
88- --jq '.workflow_runs[0].updated_at' 2>/dev/null || echo "")
89- if [ -n "$LAST_SYNC" ]; then
90- SYNC_TS=$(date -u -d "$LAST_SYNC" +%s 2>/dev/null || echo "0")
91- SYNC_AGE=$(( (NOW - SYNC_TS) / 3600 ))
92- if [ "$SYNC_AGE" -gt 12 ]; then
93- if [ -n "$STALE_ITEMS" ]; then
94- STALE_ITEMS="$STALE_ITEMS, sync-binaries (${SYNC_AGE}h ago)"
95- else
96- STALE_ITEMS="sync-binaries (${SYNC_AGE}h ago)"
91+ --jq '.workflow_runs[0].updated_at // empty' 2>/dev/null || echo "")
92+ if [ -n "$LAST_SYNC" ] && [ "$LAST_SYNC" != "null" ]; then
93+ SYNC_TS=$(date -u -d "$LAST_SYNC" +%s 2>/dev/null || echo "")
94+ if [ -n "$SYNC_TS" ] && [ "$SYNC_TS" -gt 0 ] 2>/dev/null; then
95+ SYNC_AGE=$(( (NOW - SYNC_TS) / 3600 ))
96+ if [ "$SYNC_AGE" -gt 12 ]; then
97+ if [ -n "$STALE_ITEMS" ]; then
98+ STALE_ITEMS="$STALE_ITEMS, sync-binaries (${SYNC_AGE}h ago)"
99+ else
100+ STALE_ITEMS="sync-binaries (${SYNC_AGE}h ago)"
101+ fi
97102 fi
98103 fi
99104 fi
@@ -141,9 +146,9 @@ jobs:
141146 status : failure
142147 fields : |
143148 [
144- {"name": "Registry", "value": "${{ steps.registry.outputs.status }} (HTTP ${{ steps.registry.outputs.http_code }})", "inline": true},
145- {"name": "S3 Bucket", "value": "${{ steps.s3.outputs.status }}", "inline": true},
146- {"name": "Failures (6h)", "value": "${{ steps.failures.outputs.count }}", "inline": true},
149+ {"name": "Registry", "value": "${{ steps.registry.outputs.status || 'unknown' }} (HTTP ${{ steps.registry.outputs.http_code || '?' }})", "inline": true},
150+ {"name": "S3 Bucket", "value": "${{ steps.s3.outputs.status || 'unknown' }}", "inline": true},
151+ {"name": "Failures (6h)", "value": "${{ steps.failures.outputs.count || '?' }}", "inline": true},
147152 {"name": "Stale Syncs", "value": "${{ steps.stale.outputs.items || 'none' }}", "inline": false}
148153 ]
149154 webhook_url : ${{ secrets.DISCORD_WEBHOOK_URL }}
@@ -171,8 +176,8 @@ jobs:
171176 status : success
172177 fields : |
173178 [
174- {"name": "Registry", "value": "${{ steps.registry.outputs.status }}", "inline": true},
175- {"name": "S3 Bucket", "value": "${{ steps.s3.outputs.status }}", "inline": true},
176- {"name": "Failures (6h)", "value": "${{ steps.failures.outputs.count }}", "inline": true}
179+ {"name": "Registry", "value": "${{ steps.registry.outputs.status || 'unknown' }}", "inline": true},
180+ {"name": "S3 Bucket", "value": "${{ steps.s3.outputs.status || 'unknown' }}", "inline": true},
181+ {"name": "Failures (6h)", "value": "${{ steps.failures.outputs.count || '0' }}", "inline": true}
177182 ]
178183 webhook_url : ${{ secrets.DISCORD_WEBHOOK_URL }}
0 commit comments