-
Notifications
You must be signed in to change notification settings - Fork 0
90 lines (73 loc) · 2.19 KB
/
size-report.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
name: Size report
on:
pull_request:
branches:
- main
permissions:
contents: read
pull-requests: write
jobs:
size-report:
runs-on: ubuntu-latest
steps:
- name: Checkout main branch code
uses: actions/checkout@v4
with:
ref: main
path: main-code
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 8
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 21
- name: Install dependencies
working-directory: main-code
run: pnpm install
- name: Build main branch
working-directory: main-code
run: pnpm run build
- name: Set DIST_PATH environment variable
id: set-dist-path
working-directory: main-code
run: |
echo "$(pwd)/dist"
echo "DIST_PATH=$(pwd)/dist" >> $GITHUB_ENV
- name: Checkout PR code
uses: actions/checkout@v4
- name: Install dependencies
run: pnpm install
- name: Build PR code
run: pnpm run build
- name: Calculate size
id: calculate-size
run: |
echo "$(pwd)/dist"
CURRENT_SIZE=$(pnpm tsx scripts/size-report.ts)
echo "$(CURRENT_SIZE)" >> $GITHUB_ENV
- name: Display size difference
run: |
echo "Previous Size: $PREVIOUS_SIZE"
echo "Current Size: $CURRENT_SIZE"
- name: Comment on PR
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const previousSize = process.env.PREVIOUS_SIZE;
const currentSize = process.env.CURRENT_SIZE;
const message = `
# Size Report
| | Build Size |
|-------------|-----------------|
| Main branch | ${previousSize} |
| Current PR | ${currentSize} |
`;
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
body: message,
});