8
8
env :
9
9
REPO_OWNER : " nginx"
10
10
REPO_NAME : " documentation"
11
+ FRONT_DOOR_USERNAME : ${{ secrets.FRONT_DOOR_USERNAME }}
12
+ FRONT_DOOR_PASSWORD : ${{ secrets.FRONT_DOOR_PASSWORD }}
13
+ GITHUB_PR_NUMBER : ${{ github.event.pull_request.number }}
11
14
12
15
jobs :
13
16
deploy-example-site :
24
27
auto_deploy_env : " prod"
25
28
secrets :
26
29
AZURE_CREDENTIALS : ${{secrets.AZURE_CREDENTIALS_DOCS}}
27
- AZURE_KEY_VAULT : ${{secrets.AZURE_KEY_VAULT_DOCS}}
30
+ AZURE_KEY_VAULT : ${{secrets.AZURE_KEY_VAULT_DOCS}}
31
+ lighthouseci :
32
+ if : github.event.pull_request
33
+ needs : call-docs-build-push
34
+ runs-on : ubuntu-22.04
35
+ steps :
36
+ - uses : actions/checkout@v5
37
+ with :
38
+ ref : ${{ github.event.workflow_run.head_branch }}
39
+ - uses : actions/setup-node@v5
40
+ with :
41
+ node-version : 18
42
+ - name : Installing packages
43
+ run : npm ci
44
+ - name : Generating lighthouse reports for PR and main...
45
+ run : |
46
+ node performance/lighthouse-script.js
47
+ - name : Compare the artifacts for negative differences in performance
48
+ continue-on-error : true
49
+ run : |
50
+ FIELDS=("performance" "accessibility")
51
+ for FIELD in "${FIELDS[@]}"; do
52
+ PR_VALUE=$(cat lighthouse-reports/pr-report.json | jq -r ".categories.$FIELD.score")
53
+ MAIN_VALUE=$(cat lighthouse-reports/main-report.json | jq -r ".categories.$FIELD.score")
54
+ echo "$FIELD: PR - $PR_VALUE | Main - $MAIN_VALUE"
55
+
56
+ if [ $FIELD = "performance" ]; then
57
+ LOWER_BOUND=$(echo "$MAIN_VALUE - 0.05" | bc)
58
+ UPPER_BOUND=$(echo "$MAIN_VALUE + 0.05" | bc)
59
+ if (( $(echo "$PR_VALUE < $LOWER_BOUND" | bc -l) || $(echo "$PR_VALUE > $UPPER_BOUND" | bc -l) )); then
60
+ echo "Error: $FIELD score in PR ($PR_VALUE) is less than in MAIN ($MAIN_VALUE)"
61
+ exit 1
62
+ fi
63
+ else
64
+ if (( $(echo "$PR_VALUE < $MAIN_VALUE" | bc -l) )); then
65
+ echo "Error: $FIELD score in PR ($PR_VALUE) is less than in MAIN ($MAIN_VALUE)"
66
+ exit 1
67
+ fi
68
+ fi
69
+ done
70
+ - uses : actions/upload-artifact@v4
71
+ if : ${{ !cancelled() }}
72
+ with :
73
+ name : lighthouse-reports
74
+ path : lighthouse-reports/
75
+ retention-days : 30
0 commit comments