Skip to content

Commit c6f543f

Browse files
chore: only replace file if base does not exists (#5522)
Co-authored-by: Brian Muenzenmeyer <brian.muenzenmeyer@gmail.com>
1 parent 526781f commit c6f543f

2 files changed

Lines changed: 30 additions & 23 deletions

File tree

.github/workflows/build-and-analysis.yml

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ jobs:
3535
run: echo C:\Program Files\Git\usr\bin>>"%GITHUB_PATH%"
3636

3737
- name: Git Checkout
38-
uses: actions/checkout@v3
38+
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
3939
with:
4040
fetch-depth: 2
4141

4242
- name: Restore Cache
43-
uses: actions/cache/restore@v3
43+
uses: actions/cache/restore@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
4444
with:
4545
path: |
4646
~/.npm
@@ -50,7 +50,7 @@ jobs:
5050
restore-keys: cache-
5151

5252
- name: Set up Node.js
53-
uses: actions/setup-node@v3
53+
uses: actions/setup-node@e33196f7422957bea03ed53f6fbb155025ffc7b8
5454
with:
5555
node-version-file: '.nvmrc'
5656
cache: 'npm'
@@ -70,13 +70,13 @@ jobs:
7070
run: npx -p nextjs-bundle-analysis report
7171

7272
- name: Upload Build Analysis
73-
uses: actions/upload-artifact@v3
73+
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce
7474
with:
7575
name: bundle-analysis
7676
path: .next/analyze/__bundle_analysis.json
7777

7878
- name: Save Cache
79-
uses: actions/cache/save@v3
79+
uses: actions/cache/save@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
8080
with:
8181
path: |
8282
~/.npm
@@ -91,10 +91,10 @@ jobs:
9191

9292
steps:
9393
- name: Git Checkout
94-
uses: actions/checkout@v3
94+
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
9595

9696
- name: Restore Cache
97-
uses: actions/cache/restore@v3
97+
uses: actions/cache/restore@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
9898
with:
9999
path: |
100100
~/.npm
@@ -104,25 +104,32 @@ jobs:
104104
restore-keys: cache-
105105

106106
- name: Download PR Bundle Analysis
107-
uses: actions/download-artifact@v3
107+
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a
108108
with:
109109
name: bundle-analysis
110110
path: .next/analyze
111111

112-
- name: Copy PR Bundle Analysis (Fallback)
113-
run: |
114-
mkdir -p .next/analyze/base/bundle/
115-
cp .next/analyze/__bundle_analysis.json .next/analyze/base/bundle/__bundle_analysis.json
116-
117112
- name: Download Base Bundle Analysis
118-
uses: dawidd6/action-download-artifact@v2
113+
uses: dawidd6/action-download-artifact@246dbf436b23d7c49e21a7ab8204ca9ecd1fe615
119114
if: success() && github.event.number
120115
with:
121116
name: bundle-analysis
122117
branch: ${{ github.event.pull_request.base.ref }}
123118
path: .next/analyze/base/bundle
124119
if_no_artifact_found: warn
125120

121+
- name: Check Base Bundle Analysis File
122+
id: check-base-bundle-analysis-file
123+
uses: andstor/file-existence-action@20b4d2e596410855db8f9ca21e96fbe18e12930b
124+
with:
125+
files: .next/analyze/base/bundle/__bundle_analysis.json
126+
127+
- name: Copy PR Bundle Analysis (Fallback)
128+
if: steps.check-base-bundle-analysis-file.outputs.files_exists == 'true'
129+
run: |
130+
mkdir -p .next/analyze/base/bundle/
131+
cp .next/analyze/__bundle_analysis.json .next/analyze/base/bundle/__bundle_analysis.json
132+
126133
- name: Compare with base branch bundle
127134
if: success() && github.event.number
128135
run: ls -laR .next/analyze/base && npx -p nextjs-bundle-analysis compare
@@ -136,22 +143,22 @@ jobs:
136143
echo EOF >> $GITHUB_OUTPUT
137144
138145
- name: Find Comment
139-
uses: peter-evans/find-comment@v2
146+
uses: peter-evans/find-comment@a54c31d7fa095754bfef525c0c8e5e5674c4b4b1
140147
if: success() && github.event.number
141148
id: find-comment-id
142149
with:
143150
issue-number: ${{ github.event.number }}
144151
body-includes: '<!-- __NEXTJS_BUNDLE_nodejs.org -->'
145152

146153
- name: Create Comment
147-
uses: peter-evans/create-or-update-comment@v2
154+
uses: peter-evans/create-or-update-comment@c6c9a1a66007646a28c153e2a8580a5bad27bcfa
148155
if: success() && github.event.number && steps.find-comment-id.outputs.comment-id == 0
149156
with:
150157
issue-number: ${{ github.event.number }}
151158
body: ${{ steps.get-comment-body.outputs.body }}
152159

153160
- name: Update Comment
154-
uses: peter-evans/create-or-update-comment@v2
161+
uses: peter-evans/create-or-update-comment@c6c9a1a66007646a28c153e2a8580a5bad27bcfa
155162
if: success() && github.event.number && steps.find-comment-id.outputs.comment-id != 0
156163
with:
157164
issue-number: ${{ github.event.number }}

.github/workflows/pull-request.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ jobs:
2121

2222
steps:
2323
- name: Git Checkout
24-
uses: actions/checkout@v3
24+
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
2525
with:
2626
fetch-depth: 2
2727

2828
- name: Restore Cache
29-
uses: actions/cache/restore@v3
29+
uses: actions/cache/restore@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
3030
with:
3131
path: |
3232
~/.npm
@@ -36,7 +36,7 @@ jobs:
3636
restore-keys: cache-
3737

3838
- name: Set up Node.js
39-
uses: actions/setup-node@v3
39+
uses: actions/setup-node@e33196f7422957bea03ed53f6fbb155025ffc7b8
4040
with:
4141
node-version-file: '.nvmrc'
4242
cache: 'npm'
@@ -72,12 +72,12 @@ jobs:
7272
run: echo C:\Program Files\Git\usr\bin>>"%GITHUB_PATH%"
7373

7474
- name: Git Checkout
75-
uses: actions/checkout@v3
75+
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
7676
with:
7777
fetch-depth: 2
7878

7979
- name: Restore Cache
80-
uses: actions/cache/restore@v3
80+
uses: actions/cache/restore@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
8181
with:
8282
path: |
8383
~/.npm
@@ -87,7 +87,7 @@ jobs:
8787
restore-keys: cache-
8888

8989
- name: Set up Node.js
90-
uses: actions/setup-node@v3
90+
uses: actions/setup-node@e33196f7422957bea03ed53f6fbb155025ffc7b8
9191
with:
9292
node-version-file: '.nvmrc'
9393
cache: 'npm'

0 commit comments

Comments
 (0)