-
Notifications
You must be signed in to change notification settings - Fork 0
79 lines (65 loc) · 2.14 KB
/
Copy pathpr-diff-size.yml
File metadata and controls
79 lines (65 loc) · 2.14 KB
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: Packages size analysis
on:
pull_request:
branches: [main]
types: [opened, synchronize, reopened, ready_for_review]
permissions:
contents: read
pull-requests: write
actions: read
jobs:
analyze:
if: github.repository == 'rameel/ramstack.hotkey.js'
name: Analyze package size changes
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: latest
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '24'
cache: 'pnpm'
- name: Install dependencies
run: pnpm install
- name: Prepate report path
run: echo "SIZE_REPORT_OUTPUT=$RUNNER_TEMP/comment-${{ github.event.pull_request.number }}.md" >> $GITHUB_ENV
- name: Run size comparison
run: pnpm size-report
env:
NODE_ENV: production
SKIP_GIT_TAG_RESOLUTION: true
- name: Comment PR
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const body = fs.readFileSync(process.env.SIZE_REPORT_OUTPUT, 'utf8');
const pr_number = context.issue.number;
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pr_number
});
const marker = "### 📦 Bundle size comparison";
const existing_comment = comments.find(c => c.body.includes(marker));
if (existing_comment) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existing_comment.id,
body: body
});
}
else {
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: body
})
}