Skip to content

Commit 5e9adc2

Browse files
committed
ci: write pr number to artifact
1 parent f46bd37 commit 5e9adc2

File tree

2 files changed

+26
-31
lines changed

2 files changed

+26
-31
lines changed

.github/workflows/size-comment.yml

Lines changed: 17 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -18,37 +18,32 @@ jobs:
1818
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
1919
with:
2020
node-version: latest
21-
- name: 🔍 Get PR number
22-
id: pr
23-
uses: actions/github-script@v8
24-
with:
25-
script: |
26-
const pulls = await github.rest.repos.listPullRequestsAssociatedWithCommit({
27-
owner: context.repo.owner,
28-
repo: context.repo.repo,
29-
commit_sha: context.payload.workflow_run.head_sha,
30-
});
31-
32-
if (pulls.data.length > 0) {
33-
return pulls.data[0].number;
34-
}
35-
return null;
36-
21+
3722
- name: ⏬ Download artifacts from workflow run
38-
if: steps.pr.outputs.result
39-
uses: actions/download-artifact@v5
23+
uses: actions/download-artifact@v4
4024
with:
4125
github-token: ${{ secrets.GITHUB_TOKEN }}
4226
run-id: ${{ github.event.workflow_run.id }}
27+
path: .
28+
29+
- name: 🔍 Get PR number from artifact
30+
id: pr
31+
run: |
32+
if [ -f pr-number/pr-number.txt ]; then
33+
PR_NUMBER=$(cat pr-number/pr-number.txt)
34+
echo "result=$PR_NUMBER" >> $GITHUB_OUTPUT
35+
echo "Found PR number: $PR_NUMBER"
36+
else
37+
echo "PR number file not found"
38+
echo "result=" >> $GITHUB_OUTPUT
39+
fi
4340
4441
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
45-
if: steps.pr.outputs.result
4642
with:
4743
sparse-checkout: scripts/parse-sizes.ts
4844
sparse-checkout-cone-mode: false
4945

5046
- name: 📊 Generate size comparison
51-
if: steps.pr.outputs.result
5247
id: sizes
5348
run: |
5449
COMMENT=$(node scripts/parse-sizes.ts nuxi nuxt-cli create-nuxt)
@@ -57,7 +52,6 @@ jobs:
5752
echo "EOF" >> $GITHUB_OUTPUT
5853
5954
- name: 💬 Post or update comment
60-
if: steps.pr.outputs.result
6155
uses: actions/github-script@v8
6256
with:
6357
script: |
@@ -77,23 +71,15 @@ jobs:
7771
);
7872
7973
if (botComment) {
80-
// Update existing comment
74+
console.log(`Updating existing comment ${botComment.id}`);
8175
await github.rest.issues.updateComment({
8276
owner: context.repo.owner,
8377
repo: context.repo.repo,
8478
comment_id: botComment.id,
8579
body: commentBody
8680
});
8781
} else {
88-
// Create new comment
89-
await github.rest.issues.createComment({
90-
owner: context.repo.owner,
91-
repo: context.repo.repo,
92-
issue_number: prNumber,
93-
body: commentBody
94-
});
95-
} else {
96-
// Create new comment
82+
console.log('Creating new comment');
9783
await github.rest.issues.createComment({
9884
owner: context.repo.owner,
9985
repo: context.repo.repo,

.github/workflows/size.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,21 @@ jobs:
3232

3333
- name: 🛠 Build project
3434
run: pnpm build
35+
36+
- name: 💾 Save PR number
37+
run: echo "${{ github.event.pull_request.number }}" > pr-number.txt
3538

3639
- name: ⏫ Upload stats.json
3740
uses: actions/upload-artifact@v4
3841
with:
3942
name: head-stats
4043
path: ./packages/*/stats.json
44+
45+
- name: ⏫ Upload PR number
46+
uses: actions/upload-artifact@v4
47+
with:
48+
name: pr-number
49+
path: pr-number.txt
4150

4251
# Build base for comparison and upload stats.json
4352
# You may replace this with your own build method. All that

0 commit comments

Comments
 (0)