This repository has been archived by the owner on Jul 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 53
106 lines (91 loc) · 3.15 KB
/
ci.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
98
99
100
101
102
103
104
105
106
name: Continuous Integration
on:
pull_request:
workflow_dispatch:
push:
branches:
- main
jobs:
check:
runs-on: ubuntu-latest
if: "! contains(github.event.head_commit.message, '[CI Skip]')"
steps:
- uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
- name: Install
run: yarn install --immutable --immutable-cache --check-cache
- name: Checks
run: yarn check:all
- name: Audit
run: yarn
continue-on-error: true
- name: Test
run: yarn test:unit
# Continuously deploys the content of main branch
deploy:
runs-on: ubuntu-latest
needs: check
if: github.event_name == 'push'
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
- name: Install
run: yarn install --immutable --immutable-cache --check-cache
- name: Setup Pages
id: pages
uses: actions/configure-pages@v3
- name: Build
run: yarn build
env:
PUBLIC_URL: ${{ steps.pages.outputs.base_url }}
- name: Upload artifact
# Automatically uploads an artifact from the './_site' directory by default
uses: actions/upload-pages-artifact@v1
with:
path: dist/
retention-days: 10
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
- name: Audit URLs using Lighthouse
uses: treosh/lighthouse-ci-action@v10
id: lighthouse
with:
urls: |
${{ steps.pages.outputs.base_url }}
# See https://github.com/GoogleChrome/budget.json
budgetPath: .github/workflows/budget.json
- name: Format lighthouse score
id: lighthouse-score
uses: actions/github-script@v6
with:
script: |
const result = ${{ steps.lighthouse.outputs.manifest }}[0].summary;
const formatResult = (res) => Math.round((res * 100));
Object.keys(result).forEach(key => result[key] = formatResult(result[key]));
const score = res => res >= 90 ? '🟢' : res >= 50 ? '🟠' : '🔴';
const comment = [
`⚡️ Lighthouse report for the changes in this PR:`,
'| Category | Score |',
'| --- | --- |',
`| ${score(result.performance)} Performance | ${result.performance} |`,
`| ${score(result.accessibility)} Accessibility | ${result.accessibility} |`,
`| ${score(result['best-practices'])} Best practices | ${result['best-practices']} |`,
`| ${score(result.seo)} SEO | ${result.seo} |`,
`| ${score(result.pwa)} PWA | ${result.pwa} |`
].join('\n');
core.setOutput("comment", comment);
- name: Add comment to PR
uses: marocchino/sticky-pull-request-comment@v2
with:
header: lighthouse
message: |
${{ steps.lighthouse-score.outputs.comment }}