-
Notifications
You must be signed in to change notification settings - Fork 0
41 lines (36 loc) · 1.28 KB
/
analyze_bundle.yaml
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
name: Report bundle size in PR
on:
- pull_request
jobs:
bundle-size:
runs-on: ubuntu-latest
if: github.actor != 'renovate'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- run: corepack enable
- uses: actions/setup-node@v4
with:
node-version: 20
cache: "pnpm"
- name: Install dependencies
run: pnpm install
- name: Generate types
run: pnpm exec nuxi prepare
- name: Run nuxi analyze
run: pnpm exec nuxi analyze --no-serve
- name: Get values
run: |
CLIENT_BUNDLE=$(jq .size.clientBundle .nuxt/analyze/meta.json)
NITRO_BUNDLE=$(jq .size.nitroBundle .nuxt/analyze/meta.json)
echo "clientBundle=$CLIENT_BUNDLE" >> "$GITHUB_ENV"
echo "nitroBundle=$NITRO_BUNDLE" >> "$GITHUB_ENV"
shell: bash
- name: Create PR comment # TODO: https://github.com/peter-evans/create-or-update-comment
run: |
COMMENT="Client bundle: $((clientBundle / 1024)) KB, Server bundle: $((nitroBundle / 1024)) KB"
COMMENT_URL=$(gh pr comment ${{ github.event.number }} --body "$COMMENT")
COMMENT_ID=${COMMENT_URL##*issuecomment-}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}