-
Notifications
You must be signed in to change notification settings - Fork 3
62 lines (51 loc) · 1.76 KB
/
lighthouse.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
51
52
53
54
55
56
57
58
59
60
61
62
name: Lighthouse Audit
on:
push:
branches:
- '*'
tags:
- '*'
paths:
- '*'
workflow_dispatch:
inputs:
version:
description: Bump Version
default: v1.0.0
required: true
jobs:
lighthouse:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '20'
- name: Install Dependencies
run: npm install -g lighthouse
- name: Run Lighthouse
run: |
lighthouse --no-enable-error-reporting --chrome-flags="--headless --disable-gpu" https://www.npmjs.com/package/@spotify/lighthouse-audit-service --output json html --output-path=./.lighthouseci/one-platform-test-env
- name: Commit Lighthouse Reports
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GIT_TOKEN }}
script: |
const fs = require('fs');
const path = require('path');
// Import GitHub context
const github = require('@actions/github');
// Read the contents of the reports directory
const reportsPath = '.lighthouseci';
const reports = fs.readdirSync(reportsPath);
// Commit the reports to the repository
const { data } = await github.rest.repos.createOrUpdateFile({
owner: github.context.repo.owner,
repo: github.context.repo.repo,
path: 'lighthouse-reports',
message: 'Add Lighthouse Reports',
content: Buffer.from(reports.join('\n')).toString('base64'),
});
console.log(`Lighthouse reports committed. SHA: ${data.content.sha}`);