-
Notifications
You must be signed in to change notification settings - Fork 13
57 lines (50 loc) · 1.84 KB
/
Copy pathpkg-size.yml
File metadata and controls
57 lines (50 loc) · 1.84 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
name: Pkg Size
on:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
contents: read
issues: write
pull-requests: write
jobs:
pkg-size:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 24
- run: npm ci
- run: npm run build
- name: Get pack size
id: size
run: |
PACK=$(npm pack --dry-run --json 2>&1 | sed -n '/^\[/,/^\]/p' | jq '.[0]')
echo "size=$(echo "$PACK" | jq '.size')" >> "$GITHUB_OUTPUT"
echo "unpack_size=$(echo "$PACK" | jq '.unpackedSize')" >> "$GITHUB_OUTPUT"
- name: Get base branch size
if: github.event_name == 'pull_request'
id: base_size
run: |
git fetch origin ${{ github.base_ref }} --depth=1
git checkout FETCH_HEAD -- . 2>/dev/null || true
npm ci
npm run build
PACK=$(npm pack --dry-run --json 2>&1 | sed -n '/^\[/,/^\]/p' | jq '.[0]')
echo "size=$(echo "$PACK" | jq '.size')" >> "$GITHUB_OUTPUT"
echo "unpack_size=$(echo "$PACK" | jq '.unpackedSize')" >> "$GITHUB_OUTPUT"
- name: Comment on PR
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const run = require('./scripts/pkg-size-comment.cjs');
await run({
github, context,
size: parseInt('${{ steps.size.outputs.size }}'),
unpackSize: parseInt('${{ steps.size.outputs.unpack_size }}'),
baseSize: parseInt('${{ steps.base_size.outputs.size }}') || parseInt('${{ steps.size.outputs.size }}'),
baseUnpackSize: parseInt('${{ steps.base_size.outputs.unpack_size }}') || parseInt('${{ steps.size.outputs.unpack_size }}'),
});