-
Notifications
You must be signed in to change notification settings - Fork 37
79 lines (64 loc) · 4.96 KB
/
bundle-size-analysis.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
name: Bundle Size Analysis
on:
pull_request:
branches: [main]
paths:
- 'package.json'
- 'bun.lockb'
- '.github/workflows/bundle-size-analysis.yml'
permissions:
contents: read
pull-requests: write
issues: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- name: Install dependencies
run: bun install
- name: Build PR branch with stats
run: |
VITE_BUNDLE_ANALYZE=true bun run build --mode production
- name: Save stats as artifact
if: success()
uses: actions/upload-artifact@v3
with:
name: bundle-stats
path: dist/stats.html
- name: Checkout main branch
uses: actions/checkout@v4
with:
ref: main
path: main-branch
- name: Build main branch stats
run: |
cd main-branch
bun install
VITE_BUNDLE_ANALYZE=true bun run build --mode production
cd ..
- name: Generate bundle stats
id: bundle-stats
run: |
node scripts/generate_bundle_stats.js dist/stats.html main-branch/dist/stats.html
echo 'STATS_CONTENT<<EOF' >> $GITHUB_ENV
cat dist/bundle_stats.md >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
- name: Read and post stats
if: success()
uses: mshick/add-pr-comment@v2
with:
message: |
## 📊 Bundle Size Analysis
${{ env.STATS_CONTENT }}
<details>
<summary>What is this?</summary>
This is an automated bundle size report generated during the build process.
</details>
proxy-url: https://add-pr-comment-proxy-tscircuit.vercel.app/api
repo-token: ${{ secrets.GITHUB_TOKEN }}
allow-repeats: false