@@ -29,16 +29,26 @@ jobs:
29
29
run : |
30
30
PREVIEW_URL="https://deploy-preview-${{ github.event.pull_request.number }}--expressjscom-preview.netlify.app"
31
31
echo "PREVIEW_URL=$PREVIEW_URL" >> "$GITHUB_ENV"
32
- for i in {1..4}; do
33
- if curl -s --head "$PREVIEW_URL" | grep "200 OK" > /dev/null; then
34
- echo "Preview is live!"
35
- break
32
+ MAX_RETRIES=12
33
+ DELAY=10
34
+
35
+ echo "Checking Netlify preview: $PREVIEW_URL"
36
+ for i in $(seq 1 $MAX_RETRIES); do
37
+ if curl -s --head --max-time 5 "$PREVIEW_URL" | grep "200 OK" > /dev/null; then
38
+ echo "✅ Preview is live!"
39
+ echo "skip_lighthouse=false" >> "$GITHUB_ENV"
40
+ exit 0
36
41
fi
37
- echo "Waiting for Netlify to deploy... ($i/4 )"
38
- sleep 10
42
+ echo "⏳ Waiting for Netlify to deploy... ($i/$MAX_RETRIES )"
43
+ sleep $DELAY
39
44
done
40
45
46
+ echo "❌ Preview not live after $((MAX_RETRIES*DELAY)) seconds."
47
+ echo "skip_lighthouse=true" >> "$GITHUB_ENV"
48
+ exit 0
49
+
41
50
- name : Run Lighthouse audits
51
+ if : env.skip_lighthouse == 'false'
42
52
run : |
43
53
URLS=(
44
54
"$PREVIEW_URL"
@@ -88,17 +98,20 @@ jobs:
88
98
done
89
99
90
100
- name : Log Lighthouse report
101
+ if : env.skip_lighthouse == 'false'
91
102
run : |
92
103
cat lighthouse-report.md
93
104
94
105
- name : Upload Lighthouse reports as artifacts
106
+ if : env.skip_lighthouse == 'false'
95
107
uses : actions/upload-artifact@v4
96
108
with :
97
109
name : lighthouse-reports
98
110
path : |
99
111
lighthouse-report.md
100
112
101
113
- name : Comment on PR with Lighthouse results
114
+ if : env.skip_lighthouse == 'false'
102
115
uses : actions/github-script@v7
103
116
with :
104
117
github-token : ${{ secrets.GITHUB_TOKEN }}
0 commit comments