-
Notifications
You must be signed in to change notification settings - Fork 3
84 lines (66 loc) · 2.24 KB
/
main.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
name: main
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
with:
version: 6
- uses: actions/setup-node@v2
with:
node-version: 18
cache: pnpm
- run: pnpm install --frozen-lockfile
- run: npm run type
- run: npm run lint
- run: npm run test --ci
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
with:
version: 6
- uses: actions/setup-node@v2
with:
node-version: 18
cache: pnpm
- run: pnpm install --frozen-lockfile
- run: npm run build
- uses: actions/upload-artifact@v2
with:
name: build
path: ./dist/*
- name: generate badge
uses: actions/github-script@v6
with:
script: |
const fs=require('fs');
const s=fs.statSync('dist/bundle.zip').size;
const content={label:'size',message:(s/1024).toFixed(2)+'K',color:s<13312?'success':'important'};
fs.writeFileSync('dist/shieldio_size.json',JSON.stringify(content))
- name: copy images
run: cp -R doc/images dist/images
- name: deploy to gh-pages
uses: crazy-max/ghaction-github-pages@v2
if: success() && github.ref == 'refs/heads/master'
with:
build_dir: dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
analyze-bundle:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v2
- uses: actions/download-artifact@v2
with:
name: github-pages
- name: test the bundle against the report endpoint
run: |
curl --silent -X POST --max-time 120 --connect-timeout 120 --form bundle=@bundle.zip --form category=desktop https://iw8sii1h9b.execute-api.eu-west-1.amazonaws.com/stage/analyze-bundle > report.json
node -e "console.log(JSON.stringify(require('./report.json'),null,2))"
- name: fails if the report failed
run: node -e "for (const c of require('./report.json').checks){if(c.result!=='ok'){console.error(c);throw c.description;}}"