-
Notifications
You must be signed in to change notification settings - Fork 0
97 lines (88 loc) · 3.4 KB
/
test-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
name: ⛵️ Lighthouse
run-name: "${{ inputs.env == 'prd' && 'PRD' || 'STG' }} - Lighthouse Run for ${{ github.event_name == 'pull_request' && format('PR #{0}: {1}', github.event.pull_request.number, github.event.pull_request.title) || format('latest {0}', github.ref_name) }}"
on:
workflow_dispatch:
workflow_call:
inputs:
env:
description: "Target deployment environment."
type: string
required: true
secrets:
AWS_S3_BUCKET_REPORTS:
required: true
AWS_ACCESS_KEY_ID:
required: true
AWS_SECRET_ACCESS_KEY:
required: true
AWS_REGION:
required: true
REPORTS_DISTRIBUTION:
required: true
GH_WORKFLOW_TOKEN:
required: true
env:
NODE_VERSION: 20
jobs:
lighthouse:
name: ⛵️ Lighthouse
runs-on: ubuntu-latest
environment:
name: ${{ inputs.env }}
url: "https://${{ vars.WWW_DOMAIN }}"
steps:
- name: 𐂷 Checkout
uses: actions/checkout@v4
with:
repository: dgrebb/dgrebb.com
ref: ${{ github.ref }}
token: ${{ github.token }}
fetch-depth: 1
sparse-checkout: |
.github/actions
_ci
- name: 🛢 Install Dependencies
uses: ./.github/actions/install-cache-deps
with:
WORKSPACE_ROOT: _ci/perf
- name: 🔦 Lighthouse
id: lighthouse
continue-on-error: true
run: |
cd _ci/perf/lighthouse
urls="${{ vars.LIGHTHOUSE_URLS }}"
while IFS="" read -r url || [ -n "$url" ]; do
u="$(echo "$url" | tr -d '\r')"
undurl=$(echo "$u" | sed -E 's|https?://([^/]+)(/[^?#]*)?([?#]?.*)?|\2|;s|/+$||;s|/|_|g')
automation_url="${u}?roboto"
echo "Running Lighthouse on $u and writing report to ./$undurl"
pnpm lhgh $automation_url --output-path ./mobile_"$undurl"report.html --disable-extensions --force-prefers-reduced-motion
pnpm lhgh-d $automation_url --output-path ./desktop_"$undurl"report.html --disable-extensions --force-prefers-reduced-motion
done <<<"$urls"
- name: ⚓️ Drop Anchor
if: always()
run: |
ls -la _ci/perf/lighthouse
sudo _ci/perf/_utils/landfall.sh _ci/perf/lighthouse
echo "# Lighthouse Results" >> $GITHUB_STEP_SUMMARY
echo "<a href=\"https://${{ vars.REPORTS_DOMAIN }}/lighthouse\" target=\"_blank\">Lighthouse Reports</a>" >> $GITHUB_STEP_SUMMARY
- name: ⬆ Upload Reports
if: always()
uses: jakejarvis/s3-sync-action@master
with:
args: --acl public-read --follow-symlinks --delete --exclude '*.js' --cache-control max-age=2853200,public
env:
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET_REPORTS }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
SOURCE_DIR: "_ci/perf/lighthouse"
DEST_DIR: "lighthouse"
- name: ∅ Invalidate CloudFront
uses: chetan/invalidate-cloudfront-action@v2
env:
DISTRIBUTION: ${{ secrets.REPORTS_DISTRIBUTION }}
PATHS: "/*"
AWS_REGION: ${{ secrets.AWS_REGION }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}