-
Notifications
You must be signed in to change notification settings - Fork 0
55 lines (46 loc) · 1.85 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
name: Lighthouse
on:
pull_request:
types:
- review_requested
jobs:
lighthouse:
name: Lighthouse Auditing
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.node_version }}
- name: Install dependencies
run: npm install
- name: Create .env file from .env.example
run: cat .env.example > .env
- name: Build application
run: npm run build
- name: Generate URLs
id: urls
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const globber = await glob.create('**/src/routes/**/+page.svelte');
const files = await globber.glob();
const urls = files
.map(x => x.match(/routes\/([a-zA-Z\/\[\]]*?)\/?\+page\.svelte/)[1])
.map(x => x.replace('[paperId]', '42').replace('[projectId]', '12'))
.map(x => `http://localhost:8080/${x}`)
.join('\n');
core.setOutput('urls', urls);
# Add '& echo ...' to run command in background
- name: Serve website
run: npm run preview -- --port 8080 & echo "Server started on http://localhost:8080"
- name: Audit URLs using Lighthouse
uses: treosh/lighthouse-ci-action@v12
with:
urls: |
${{ steps.urls.outputs.urls }}
uploadArtifacts: true
configPath: .github/lighthouserc.json