-
Notifications
You must be signed in to change notification settings - Fork 7
149 lines (130 loc) · 4.7 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
name: Lighthouse
on:
deployment_status:
jobs:
lighthouse-run-preview-desktop:
name: Desktop Audit (Preview)
if: github.event.deployment_status.state == 'success' && github.event.deployment_status.environment == 'Preview'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run Lighthouse
uses: ./.github/actions/run-lighthouse
id: lighthouse
with:
profile: desktop
- name: Add Lighthouse stats as comment
if: always()
uses: mshick/add-pr-comment@v2
with:
message-id: lighthouse-desktop
message-failure: |
### ❌ Unable to get lighthouse scores
message: ${{ steps.lighthouse.outputs.comment }}
lighthouse-run-preview-mobile:
name: Mobile Audit (Preview)
if: github.event.deployment_status.state == 'success' && github.event.deployment_status.environment == 'Preview'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run Lighthouse
uses: ./.github/actions/run-lighthouse
id: lighthouse
with:
profile: mobile
- name: Add Lighthouse stats as comment
if: always()
uses: mshick/add-pr-comment@v2
with:
message-id: lighthouse-mobile
message-failure: |
### ❌ Unable to get lighthouse scores
message: ${{ steps.lighthouse.outputs.comment }}
lighthouse-run-production-desktop:
name: Desktop Audit (Production)
if: github.event.deployment_status.state == 'success' && github.event.deployment_status.environment == 'Production'
runs-on: ubuntu-latest
env:
LIGHTHOUSE_BRANCH: 'main'
LIGHTHOUSE_FILE: 'README.md'
LIGHTHOUSE_BEGIN_TOKEN: '<!-- LIGHTHOUSE:BEGIN -->'
LIGHTHOUSE_END_TOKEN: '<!-- LIGHTHOUSE:END -->'
steps:
- uses: actions/checkout@v3
with:
# Required due to branch protection rules - must be a repo admin
token: ${{ secrets.PROTECTED_PUSH_TOKEN }}
ref: ${{ env.LIGHTHOUSE_BRANCH }}
- name: Run Lighthouse
uses: ./.github/actions/run-lighthouse
id: lighthouse
with:
profile: desktop
- name: Add Lighthouse to README.md
if: always()
run: |
begin=$LIGHTHOUSE_BEGIN_TOKEN
end=$LIGHTHOUSE_END_TOKEN
file=$LIGHTHOUSE_FILE
data="${{ steps.lighthouse.outputs.comment }}"
awk -i inplace \
-v begin="$begin" \
-v end="$end" \
-v data="$data" '$0~end{f=0} !f{print} $0~begin{print data;f=1}' \
"$file"
- name: Commit to repo
if: always()
uses: stefanzweifel/git-auto-commit-action@v4
env:
GITHUB_TOKEN: ${{ secrets.PROTECTED_PUSH_TOKEN }}
with:
commit_message: Lighthouse Score [skip ci]
skip_dirty_check: true
file_pattern: README.md
commit_user_name: lighthouse-action
commit_user_email: actions@github.com
commit_author: lighthouse-action <actions@github.com>
lighthouse-run-production-mobile:
name: Mobile Audit (Production)
if: github.event.deployment_status.state == 'success' && github.event.deployment_status.environment == 'Production'
runs-on: ubuntu-latest
env:
LIGHTHOUSE_BRANCH: 'main'
LIGHTHOUSE_FILE: 'README.md'
LIGHTHOUSE_BEGIN_TOKEN: '<!-- LIGHTHOUSE:BEGIN -->'
LIGHTHOUSE_END_TOKEN: '<!-- LIGHTHOUSE:END -->'
steps:
- uses: actions/checkout@v3
with:
# Required due to branch protection rules - must be a repo admin
token: ${{ secrets.PROTECTED_PUSH_TOKEN }}
ref: ${{ env.LIGHTHOUSE_BRANCH }}
- name: Run Lighthouse
uses: ./.github/actions/run-lighthouse
id: lighthouse
with:
profile: mobile
- name: Add Lighthouse to README.md
if: always()
run: |
begin=$LIGHTHOUSE_BEGIN_TOKEN
end=$LIGHTHOUSE_END_TOKEN
file=$LIGHTHOUSE_FILE
data="${{ steps.lighthouse.outputs.comment }}"
awk -i inplace \
-v begin="$begin" \
-v end="$end" \
-v data="$data" '$0~end{f=0} !f{print} $0~begin{print data;f=1}' \
"$file"
- name: Commit to repo
if: always()
uses: stefanzweifel/git-auto-commit-action@v4
env:
GITHUB_TOKEN: ${{ secrets.PROTECTED_PUSH_TOKEN }}
with:
commit_message: Lighthouse Score [skip ci]
skip_dirty_check: true
file_pattern: README.md
commit_user_name: lighthouse-action
commit_user_email: actions@github.com
commit_author: lighthouse-action <actions@github.com>