Skip to content

Commit 25ac9d0

Browse files
committed
Try to fix it
1 parent 6a9f6c8 commit 25ac9d0

2 files changed

Lines changed: 37 additions & 14 deletions

File tree

.github/workflows/bundle_analysis_upload.yml renamed to .github/workflows/analyze.yml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1-
name: Bundle Analysis Upload
2-
on: pull_request
1+
name: Analyze Bundle
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main # change this if your default branch is named differently
8+
workflow_dispatch:
39

410
jobs:
511
analyze:
@@ -77,5 +83,14 @@ jobs:
7783
name: analysis_comment.txt
7884
path: beta/.next/analyze/__bundle_analysis_comment.txt
7985

86+
- name: Save PR number
87+
run: echo ${{ github.event.number }} > ./pr-number
88+
89+
- name: Upload PR number
90+
uses: actions/upload-artifact@v2
91+
with:
92+
name: pr-number
93+
path: ./pr-number
94+
8095
# The actual commenting happens in the other action, matching the guidance in
8196
# https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,37 @@
1-
name: Bundle Analysis Comment
1+
name: Analyze Bundle (Comment)
22

33
on:
44
workflow_run:
5-
workflows: ["Bundle Analysis Upload"]
5+
workflows: ["Analyze Bundle"]
66
types:
77
- completed
88

99
jobs:
10-
comment:
10+
upload:
1111
runs-on: ubuntu-latest
1212
if: >
1313
${{ github.event.workflow_run.event == 'pull_request' &&
1414
github.event.workflow_run.conclusion == 'success' }}
1515
steps:
1616
- name: Download base branch bundle stats
1717
uses: dawidd6/action-download-artifact@v2
18-
if: success() && github.event.number
1918
with:
20-
workflow: bundle_analysis_upload.yml
19+
workflow: analyze.yml
2120
name: analysis_comment.txt
2221
path: analysis_comment.txt
2322

23+
- name: Download PR number
24+
uses: dawidd6/action-download-artifact@v2
25+
with:
26+
workflow: analyze.yml
27+
name: pr_number
28+
path: pr_number
29+
2430
- name: Get comment body
2531
id: get-comment-body
26-
if: success() && github.event.number
32+
if: success()
2733
run: |
34+
pr_number=$(cat pr_number)
2835
body=$(cat analysis_comment.txt)
2936
body="## Size Changes
3037
<details>
@@ -36,28 +43,29 @@ jobs:
3643
body="${body//$'\n'/'%0A'}"
3744
body="${body//$'\r'/'%0D'}"
3845
echo ::set-output name=body::$body
46+
echo ::set-output name=pr-number::$pr_number
3947
working-directory: beta
4048

4149
- name: Find Comment
4250
uses: peter-evans/find-comment@v1
43-
if: success() && github.event.number
51+
if: success()
4452
id: fc
4553
with:
46-
issue-number: ${{ github.event.number }}
54+
issue-number: ${{ steps.get-comment-body.outputs.pr-number }}
4755
body-includes: "<!-- __NEXTJS_BUNDLE -->"
4856

4957
- name: Create Comment
5058
uses: peter-evans/create-or-update-comment@v1.4.4
51-
if: success() && github.event.number && steps.fc.outputs.comment-id == 0
59+
if: success() && steps.fc.outputs.comment-id == 0
5260
with:
53-
issue-number: ${{ github.event.number }}
61+
issue-number: ${{ steps.get-comment-body.outputs.pr-number }}
5462
body: ${{ steps.get-comment-body.outputs.body }}
5563

5664
- name: Update Comment
5765
uses: peter-evans/create-or-update-comment@v1.4.4
58-
if: success() && github.event.number && steps.fc.outputs.comment-id != 0
66+
if: success() && steps.fc.outputs.comment-id != 0
5967
with:
60-
issue-number: ${{ github.event.number }}
68+
issue-number: ${{ steps.get-comment-body.outputs.pr-number }}
6169
body: ${{ steps.get-comment-body.outputs.body }}
6270
comment-id: ${{ steps.fc.outputs.comment-id }}
6371
edit-mode: replace

0 commit comments

Comments
 (0)