@@ -37,24 +37,36 @@ jobs:
3737 - uses : actions/checkout@v4
3838
3939 - name : Run accessibility scan - ${{ matrix.siteName }}
40+ id : scan
4041 run : |
4142 mkdir -p results
42- HTTP_STATUS=$(curl -s -o results/${{ matrix.siteName }}.sarif -w "%{http_code}" \
43- -X POST "${{ env.SCANNER_BASE_URL }}/api/ci/scan" \
44- -H "Content-Type: application/json" \
45- -d '{"url": "${{ matrix.siteUrl }}", "format": "sarif"}' \
46- --max-time 120)
43+ for attempt in 1 2 3; do
44+ HTTP_STATUS=$(curl -s -o results/${{ matrix.siteName }}.sarif -w "%{http_code}" \
45+ -X POST "${{ env.SCANNER_BASE_URL }}/api/ci/scan" \
46+ -H "Content-Type: application/json" \
47+ -d '{"url": "${{ matrix.siteUrl }}", "format": "sarif"}' \
48+ --max-time 120)
4749
48- echo "HTTP status: $HTTP_STATUS"
50+ echo "Attempt $attempt - HTTP status: $HTTP_STATUS"
4951
50- if [ "$HTTP_STATUS" -ne 200 ]; then
51- echo "::error::Scan failed for ${{ matrix.siteUrl }} (HTTP $HTTP_STATUS)"
52- cat results/${{ matrix.siteName }}.sarif
53- exit 1
54- fi
52+ if [ "$HTTP_STATUS" -eq 200 ]; then
53+ echo "SARIF file written: results/${{ matrix.siteName }}.sarif"
54+ echo "File size: $(wc -c < results/${{ matrix.siteName }}.sarif) bytes"
55+ echo "scan_ok=true" >> "$GITHUB_OUTPUT"
56+ exit 0
57+ fi
5558
56- echo "SARIF file written: results/${{ matrix.siteName }}.sarif"
57- echo "File size: $(wc -c < results/${{ matrix.siteName }}.sarif) bytes"
59+ echo "::warning::Scan attempt $attempt failed for ${{ matrix.siteUrl }} (HTTP $HTTP_STATUS)"
60+ if [ "$attempt" -lt 3 ]; then
61+ echo "Retrying in 30s..."
62+ sleep 30
63+ fi
64+ done
65+
66+ echo "::error::Scan failed for ${{ matrix.siteUrl }} after 3 attempts (HTTP $HTTP_STATUS)"
67+ cat results/${{ matrix.siteName }}.sarif
68+ echo "scan_ok=false" >> "$GITHUB_OUTPUT"
69+ exit 1
5870
5971 - name : Upload SARIF artifact - ${{ matrix.siteName }}
6072 uses : actions/upload-artifact@v4
6577
6678 - name : Upload SARIF to GitHub Security - ${{ matrix.siteName }}
6779 uses : github/codeql-action/upload-sarif@v4
68- if : always()
80+ if : steps.scan.outputs.scan_ok == 'true'
6981 with :
7082 sarif_file : results/${{ matrix.siteName }}.sarif
7183 category : a11y-${{ matrix.siteName }}
0 commit comments