Skip to content

Commit b1dd566

Browse files
fix(gh-workflow): skip comment when push directly
1 parent 9f0f1c1 commit b1dd566

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

.github/workflows/analyze.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ jobs:
4848

4949
- name: Download base branch bundle stats
5050
uses: dawidd6/action-download-artifact@v2
51-
if: success() && github.event.number
51+
if: success()
5252
with:
5353
workflow: analyze.yml
54-
branch: ${{ github.event.pull_request.base.ref }}
54+
branch: ${{ github.event.pull_request.base.ref || 'main' }}
5555
name: bundle_analysis.json
5656
path: .next/analyze/base/bundle
5757

@@ -69,14 +69,21 @@ jobs:
6969
# Either of these arguments can be changed or removed by editing the `nextBundleAnalysis`
7070
# entry in your package.json file.
7171
- name: Compare with base branch bundle
72-
if: success() && github.event.number
72+
if: success()
7373
run: ls -laR .next/analyze/base && npx -p nextjs-bundle-analysis compare
7474

7575
- name: Upload analysis comment
7676
uses: actions/upload-artifact@v2
7777
with:
7878
name: analysis_comment.txt
7979
path: .next/analyze/__bundle_analysis_comment.txt
80+
81+
number:
82+
runs-on: ubuntu-latest
83+
needs: analyze
84+
if: github.event_name == 'pull_request'
85+
steps:
86+
- uses: actions/checkout@v2
8087

8188
- name: Save PR number
8289
run: echo ${{ github.event.number }} > ./pr_number

.github/workflows/analyze_comment.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ jobs:
1010
comment:
1111
runs-on: ubuntu-latest
1212
if: >
13-
${{ github.event.workflow_run.event == 'pull_request' &&
14-
github.event.workflow_run.conclusion == 'success' }}
13+
github.event.workflow_run.workflows.event_name == 'pull_request' && github.event.workflow_run.workflows.conclusion == 'success'
1514
steps:
1615
- name: Download base branch bundle stats
1716
uses: dawidd6/action-download-artifact@v2

0 commit comments

Comments
 (0)