This repository has been archived by the owner on Jul 21, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
72 lines (60 loc) · 2.62 KB
/
report.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
name: Lighthouse report
on:
schedule:
- cron: "*/10 * * * *"
workflow_dispatch:
jobs:
lighthouse-check:
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@main
- name: Checkout the reports branch
run: |
git fetch --all
git checkout origin/reports
- name: Retrieve the configuration
id: configuration
run: |
git checkout origin/main -- "./configuration.json"
echo ::set-output name=addresses::"$(jq -r '.addresses | join(",")' < ./configuration.json)"
echo ::set-output name=emulated_form_factor::"$(jq -r '.emulated_form_factor' < ./configuration.json)"
rm ./configuration.json
- name: Create temporary directories
run: |
test -f ./reports.json || touch ./reports.json
mkdir -p /tmp/artifacts ./reports
- name: Generate the report
uses: foo-software/lighthouse-check-action@master
with:
author: ${{ github.actor }}
outputDirectory: /tmp/artifacts
urls: "${{ steps.configuration.outputs.addresses }}"
emulatedFormFactor: "${{ steps.configuration.outputs.emulated_form_factor }}"
- name: Process the report results
run: |
jq -s '.[0] + .[1]' reports.json /tmp/artifacts/results.json > /tmp/artifacts/mix.json
mv /tmp/artifacts/mix.json reports.json
for report in /tmp/artifacts/*.html; do
base="$(basename "$report")"; name="${base%.html}"; time="${name/lighthouse-report-}"
perl -ne '/<script>window.__LIGHTHOUSE_JSON__ = (.*);<\/script>/ and print $1' "$report" |
gzip > "/tmp/artifacts/$time.json.gz"
done
find /tmp/artifacts/*.json.gz | while read report; do
base="$(basename "$report")"
time="${base%.json.gz}"
cat "$report" | gunzip | jq "{\"$time\": {\"address\": .requestedUrl, \"seconds\": (.audits.interactive.numericValue / 1000) | floor}}"
done | jq -s add > /tmp/artifacts/data.json
jq -s '.[0] + .[1]' data.json /tmp/artifacts/data.json > /tmp/artifacts/mix.json
mv /tmp/artifacts/mix.json data.json
cp /tmp/artifacts/*.json.gz reports
- name: Commit the report results
uses: EndBug/add-and-commit@v4
with:
add: "*.json reports"
ref: reports
message: Add reports
author_name: "0x2b3bfa0"
author_email: "[email protected]"
env:
GITHUB_TOKEN: ${{ secrets.USER_TOKEN }}