Skip to content

Commit f5b207e

Browse files
committed
ci: split size compare workflow into two
1 parent 9c6e9c6 commit f5b207e

File tree

2 files changed

+55
-34
lines changed

2 files changed

+55
-34
lines changed

.github/workflows/size-comment.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: size-comment
2+
on:
3+
workflow_run:
4+
workflows: [size-build]
5+
types: [completed]
6+
7+
permissions:
8+
pull-requests: write
9+
issues: write
10+
actions: read
11+
12+
jobs:
13+
comment:
14+
# Only run if the build workflow succeeded and was triggered by a pull request
15+
if: >
16+
github.event.workflow_run.conclusion == 'success' &&
17+
github.event.workflow_run.event == 'pull_request'
18+
runs-on: ubuntu-latest
19+
strategy:
20+
matrix:
21+
package: [nuxi, nuxt-cli, create-nuxt]
22+
steps:
23+
- name: 🔍 Get PR number
24+
id: pr
25+
uses: actions/github-script@v7
26+
with:
27+
script: |
28+
const pulls = await github.rest.repos.listPullRequestsAssociatedWithCommit({
29+
owner: context.repo.owner,
30+
repo: context.repo.repo,
31+
commit_sha: context.payload.workflow_run.head_sha,
32+
});
33+
if (pulls.data.length > 0) {
34+
return pulls.data[0].number;
35+
}
36+
37+
- name: ⏬ Download artifacts from workflow run
38+
uses: actions/download-artifact@v4
39+
with:
40+
github-token: ${{ secrets.GITHUB_TOKEN }}
41+
run-id: ${{ github.event.workflow_run.id }}
42+
43+
- name: 📊 Compare sizes
44+
uses: twk3/[email protected]
45+
env:
46+
PR_NUMBER: ${{ steps.pr.outputs.result }}
47+
with:
48+
title: ${{ matrix.package }} size comparison
49+
github-token: ${{ secrets.GITHUB_TOKEN }}
50+
current-stats-json-path: ./head-stats/${{ matrix.package }}/stats.json
51+
base-stats-json-path: ./base-stats/${{ matrix.package }}/stats.json

.github/workflows/size.yml

Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,21 @@
1-
name: size
1+
name: size-build
22
on:
3-
# this action will error unless run in a pr context
4-
pull_request_target:
3+
pull_request:
54
branches:
65
- main
76

87
env:
98
BUNDLE_SIZE: true
109

11-
permissions: {}
10+
permissions:
11+
contents: read
1212

1313
jobs:
1414
# Build current and upload stats.json
15-
# You may replace this with your own build method. All that
16-
# is required is that the stats.json be an artifact
1715
build-head:
1816
runs-on: ubuntu-latest
19-
permissions:
20-
contents: read
2117
steps:
2218
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
23-
with:
24-
ref: ${{ github.event.pull_request.head.sha }}
2519
- run: corepack enable
2620
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
2721
with:
@@ -40,12 +34,8 @@ jobs:
4034
path: ./packages/*/stats.json
4135

4236
# Build base for comparison and upload stats.json
43-
# You may replace this with your own build method. All that
44-
# is required is that the stats.json be an artifact
4537
build-base:
4638
runs-on: ubuntu-latest
47-
permissions:
48-
contents: read
4939
steps:
5040
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
5141
with:
@@ -66,23 +56,3 @@ jobs:
6656
with:
6757
name: base-stats
6858
path: ./packages/*/stats.json
69-
70-
# run the action against the stats.json files
71-
compare:
72-
runs-on: ubuntu-latest
73-
needs: [build-base, build-head]
74-
permissions:
75-
pull-requests: write
76-
issues: write
77-
strategy:
78-
matrix:
79-
package: [nuxi, nuxt-cli, create-nuxt]
80-
steps:
81-
- name: ⏬ Download stats.json
82-
uses: actions/download-artifact@v5
83-
- uses: twk3/[email protected]
84-
with:
85-
title: ${{ matrix.package }} size comparison
86-
github-token: ${{ secrets.GITHUB_TOKEN }}
87-
current-stats-json-path: ./head-stats/${{ matrix.package }}/stats.json
88-
base-stats-json-path: ./base-stats/${{ matrix.package }}/stats.json

0 commit comments

Comments
 (0)