Skip to content

Commit 61c3c8e

Browse files
committed
ci: fix size report permissions
1 parent 1b56405 commit 61c3c8e

File tree

2 files changed

+89
-21
lines changed

2 files changed

+89
-21
lines changed

.github/workflows/size-data.yml

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: size data
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
upload:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- uses: actions/checkout@v3
20+
21+
- name: Install pnpm
22+
uses: pnpm/action-setup@v2
23+
24+
- name: Set node version to LTS
25+
uses: actions/setup-node@v3
26+
with:
27+
node-version: lts/*
28+
cache: pnpm
29+
30+
- name: Install dependencies
31+
run: PUPPETEER_SKIP_DOWNLOAD=1 pnpm install
32+
33+
- run: pnpm run size
34+
35+
- name: Upload Size Data
36+
uses: actions/upload-artifact@v3
37+
with:
38+
name: size-data
39+
path: temp/size
40+
41+
- name: Save PR number
42+
if: ${{github.event_name == 'pull_request'}}
43+
run: echo ${{ github.event.number }} > ./pr.txt
44+
45+
- uses: actions/upload-artifact@v2
46+
if: ${{github.event_name == 'pull_request'}}
47+
with:
48+
name: pr-number
49+
path: pr.txt

.github/workflows/size-report.yml

+40-21
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
name: size report
22

33
on:
4-
pull_request:
5-
branches:
6-
- main
4+
workflow_run:
5+
workflows: ['size data']
6+
types:
7+
- completed
78

89
permissions:
910
contents: read
1011
pull-requests: write
12+
issues: write
1113

1214
jobs:
13-
size:
15+
size-report:
1416
runs-on: ubuntu-latest
15-
17+
if: >
18+
github.event.workflow_run.event == 'pull_request' &&
19+
github.event.workflow_run.conclusion == 'success'
1620
steps:
1721
- uses: actions/checkout@v3
1822

@@ -25,37 +29,52 @@ jobs:
2529
node-version: lts/*
2630
cache: pnpm
2731

28-
- run: PUPPETEER_SKIP_DOWNLOAD=1 pnpm install
29-
- run: pnpm run size
32+
- name: Install dependencies
33+
run: PUPPETEER_SKIP_DOWNLOAD=1 pnpm install
3034

31-
- name: Download Previous Size Report
32-
id: download-artifact
35+
- name: Download PR number
3336
uses: dawidd6/action-download-artifact@v2
3437
with:
35-
branch: main
36-
name: size-report
37-
path: temp/size-prev
38-
if_no_artifact_found: warn
38+
name: pr-number
39+
run_id: ${{ github.event.workflow_run.id }}
40+
41+
- name: Read PR Number
42+
id: pr-number
43+
uses: juliangruber/read-file-action@v1
44+
with:
45+
path: ./pr.txt
3946

40-
- name: Upload Size Report
41-
uses: actions/upload-artifact@v3
47+
- name: Download Size Data
48+
uses: dawidd6/action-download-artifact@v2
4249
with:
43-
name: size-report
50+
name: size-data
51+
run_id: ${{ github.event.workflow_run.id }}
4452
path: temp/size
4553

54+
- name: Download Previous Size Data
55+
uses: dawidd6/action-download-artifact@v2
56+
with:
57+
branch: main
58+
workflow: size-data.yml
59+
name: size-data
60+
path: temp/size-prev
61+
if_no_artifact_found: warn
62+
4663
- name: Compare size
47-
run: pnpm tsx scripts/size-report.ts > size.md
64+
run: pnpm tsx scripts/size-report.ts > size-report.md
4865

49-
- name: Read Size Markdown
50-
id: size-markdown
66+
- name: Read Size Report
67+
id: size-report
5168
uses: juliangruber/read-file-action@v1
5269
with:
53-
path: ./size.md
70+
path: ./size-report.md
5471

5572
- name: Create Comment
5673
uses: actions-cool/maintain-one-comment@v3
5774
with:
75+
token: ${{ secrets.GITHUB_TOKEN }}
76+
number: ${{ steps.pr-number.outputs.content }}
5877
body: |
59-
${{steps.size-markdown.outputs.content}}
78+
${{ steps.size-report.outputs.content }}
6079
<!-- VUE_CORE_SIZE -->
6180
body-include: '<!-- VUE_CORE_SIZE -->'

0 commit comments

Comments
 (0)