-
Notifications
You must be signed in to change notification settings - Fork 140
93 lines (75 loc) · 3.08 KB
/
lighthouse.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
name: Lighthouse Report
on:
deployment_status:
states: ['success']
jobs:
generate_lighthouse_audit:
name: Deployment Audit
timeout-minutes: 30
runs-on: ubuntu-latest
if: ${{ contains(fromJson('["Production – catalyst-latest", "Preview – catalyst-latest"]'), github.event.deployment_status.environment) }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Lighthouse house audit on desktop
id: lighthouse_audit_desktop
uses: treosh/lighthouse-ci-action@v11
with:
urls: |
${{ github.event.deployment_status.target_url }}
configPath: '.github/workflows/.lighthouserc-desktop.json'
temporaryPublicStorage: true
runs: 3
- name: Lighthouse audit on mobile
id: lighthouse_audit_mobile
uses: treosh/lighthouse-ci-action@v11
with:
urls: |
${{ github.event.deployment_status.target_url }}
temporaryPublicStorage: true
runs: 3
- uses: pnpm/action-setup@v3
- name: Format lighthouse score on desktop
id: format_lighthouse_score_desktop
uses: actions/github-script@v7
with:
script: |
const lighthouseCommentMaker = require('./.github/workflows/lighthouseCommentMaker.js');
const lighthouseOutputs = {
manifest: ${{ steps.lighthouse_audit_desktop.outputs.manifest }},
links: ${{ steps.lighthouse_audit_desktop.outputs.links }},
preset: "desktop"
};
const comment = lighthouseCommentMaker({ lighthouseOutputs });
core.setOutput("comment", comment);
- name: Format lighthouse score on mobile
id: format_lighthouse_score_mobile
uses: actions/github-script@v7
with:
script: |
const lighthouseCommentMaker = require('./.github/workflows/lighthouseCommentMaker.js');
const lighthouseOutputs = {
manifest: ${{ steps.lighthouse_audit_mobile.outputs.manifest }},
links: ${{ steps.lighthouse_audit_mobile.outputs.links }},
preset: "mobile"
};
const comment = lighthouseCommentMaker({ lighthouseOutputs });
core.setOutput("comment", comment);
- name: Find pull request
uses: jwalton/[email protected]
id: finder
- name: Add comment to PR
id: comment_to_pr
uses: marocchino/[email protected]
with:
recreate: true
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
number: ${{ steps.finder.outputs.pr }}
header: lighthouse
message: |
# ⚡️🏠 Lighthouse report
*Lighthouse ran against ${{ github.event.deployment_status.target_url }}*
## 🖥️ Desktop
${{ steps.format_lighthouse_score_desktop.outputs.comment }}
## 📱 Mobile
${{ steps.format_lighthouse_score_mobile.outputs.comment }}