-
Notifications
You must be signed in to change notification settings - Fork 1
120 lines (117 loc) · 3.7 KB
/
bundle.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
name: Bundle
on:
push:
branches:
- master
pull_request:
env:
NODE_VERSION: 16.15.0
jobs:
base:
runs-on: ubuntu-latest
outputs:
size: ${{ steps.size.outputs.size }}
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.base_ref }}
- uses: pnpm/[email protected]
with:
version: 7
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v2
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'pnpm'
- name: Install dependencies
run: pnpm install
- name: Build
run: pnpm build
- name: Save bundle size
id: size
run: |
echo "::set-output name=size::$(du -s dist/ | awk '{print $1}')"
- name: Publish result
if: ${{ hashFiles('stats.html') != '' }}
run: pnpm dlx surge . https://${{ github.base_ref }}-stats.surge.sh --token ${{ secrets.SURGE_TOKEN }}
head:
runs-on: ubuntu-latest
outputs:
size: ${{ steps.size.outputs.size }}
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v2
- uses: pnpm/[email protected]
with:
version: 7
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v2
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'pnpm'
- name: Install dependencies
run: pnpm install
- name: Build
run: pnpm build
- name: Save bundle size
id: size
run: |
echo "::set-output name=size::$(du -s dist/ | awk '{print $1}')"
- name: Publish result
if: ${{ hashFiles('stats.html') != '' }}
run: pnpm dlx surge . https://${{ github.head_ref }}-stats.surge.sh --token ${{ secrets.SURGE_TOKEN }}
compare:
runs-on: ubuntu-latest
needs: [base, head]
if: github.event_name == 'pull_request'
steps:
- name: Find comment
id: fc
uses: peter-evans/find-comment@v2
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: 'Bundle size comparison'
- name: Create or update comment
uses: peter-evans/create-or-update-comment@v2
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.number }}
edit-mode: replace
body: |
### Bundle size comparison
- Base: [${{needs.base.outputs.size}}](https://${{ github.base_ref }}-stats.surge.sh/stats.html)
- Head: [${{needs.head.outputs.size}}](https://${{ github.head_ref }}-stats.surge.sh/stats.html)
- name: Compare bundle sizes
run: |
if [ "${{needs.base.outputs.size}}" -lt "${{needs.head.outputs.size}}" ]; then
exit 1
else
exit 0
fi
bundlewatch:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: pnpm/[email protected]
with:
version: 7
- name: Use Node.js 16.15.0
uses: actions/setup-node@v2
with:
node-version: 16.15.0
cache: 'pnpm'
- name: Install dependencies
run: pnpm install
- name: Build
run: pnpm run build
- name: Check bundle size
env:
BUNDLEWATCH_GITHUB_TOKEN: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}
GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CI_REPO_OWNER: ${{ github.repository_owner }}
CI_REPO_NAME: taskratchet-web
CI_COMMIT_SHA: ${{ github.sha }}
CI_BRANCH: ${{ github.ref_name }}
run: pnpm dlx bundlewatch