-
Notifications
You must be signed in to change notification settings - Fork 0
50 lines (43 loc) · 2.07 KB
/
lighthouse-prod.yaml
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
name: Lighthouse
on:
workflow_dispatch:
schedule:
- cron: "0 0 * * *"
jobs:
lhci:
name: Lighthouse
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- name: setup-node
uses: actions/setup-node@v4
with:
node-version: 20
- name: install Lighthouse
run: |
npm install -g lighthouse hjson
- name: install chrome
run: |
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo apt install ./google-chrome-stable_current_amd64.deb
- name: run Lighthouse
run: |
lighthouse https://walnuts.dev/ --chrome-flags="--headless" --output json --enable-error-reporting > lighthouse.json
- name: extract score
run: |
cat lighthouse.json |sed -e "/nodeLabel/D" |hjson -j | jq "[.categories[] |{(.id): .score}]| add" > score.json
- name: rewrite README.md
run: |
sed -i -e "s#https://img.shields.io/badge/Performance-.*25-green.svg#https://img.shields.io/badge/Performance-$(cat score.json |jq -r '.performance'| awk '$0=$0*100"%"')25-green.svg#g" README.md
sed -i -e "s#https://img.shields.io/badge/Accessibility-.*25-green.svg#https://img.shields.io/badge/Accessibility-$(cat score.json |jq -r '.accessibility'| awk '$0=$0*100"%"')25-green.svg#g" README.md
sed -i -e "s#https://img.shields.io/badge/Best%20Practices-.*25-green.svg#https://img.shields.io/badge/Best%20Practices-$(cat score.json |jq -r '."best-practices"'| awk '$0=$0*100"%"')25-green.svg#g" README.md
sed -i -e "s#https://img.shields.io/badge/SEO-.*25-green.svg#https://img.shields.io/badge/SEO-$(cat score.json |jq -r '.seo'| awk '$0=$0*100"%"')25-green.svg#g" README.md
- name: push
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add README.md
git commit -m "update README.md"
git pull
git push --set-upstream origin main