Allow forcing a build in artifacts workflow dispatch
Sometimes it is useful to bypass the revision check when we need to make changes to the runtime_commit_artifacts script. The `force` input can be passed via the GitHub UI for manual runs of the workflow. ghstack-source-id: cf9e32c01a565d86980277115f41e3e116adf376 Pull Request resolved: https://github.com/facebook/react/pull/31027
Lauren Tan committed
Sep 23, 2024 at 15:31 UTC
5b19dc0f06e92d3ed0aa93be3c5bbe2298da5df6
1 file changed
+15
-8
.github/workflows/runtime_commit_artifacts.yml
+15
-8
@@ -11,6 +11,11 @@ on:
11
commit_sha:
12
required: false
13
type: string
14
+ force:
15
+ description: 'Force a commit to the builds/... branches'
16
+ required: true
17
+ default: false
18
+ type: boolean
19
20
env:
21
TZ: /usr/share/zoneinfo/America/Los_Angeles
@@ -196,6 +201,7 @@ jobs:
201
grep -rl "$CURRENT_VERSION_MODERN" ./compiled | xargs -r sed -i -e "s/$CURRENT_VERSION_MODERN/$LAST_VERSION_MODERN/g"
202
grep -rl "$CURRENT_VERSION_MODERN" ./compiled || echo "Modern version reverted"
203
- name: Check for changes
204
+ if: !inputs.force
205
id: check_should_commit
206
run: |
207
echo "Full git status"
@@ -213,7 +219,7 @@ jobs:
219
echo "should_commit=false" >> "$GITHUB_OUTPUT"
220
fi
221
- name: Re-apply version changes
216
- if: steps.check_should_commit.outputs.should_commit == 'true' && needs.download_artifacts.outputs.last_version_classic != '' && needs.download_artifacts.outputs.last_version_modern != ''
222
+ if: inputs.force || (steps.check_should_commit.outputs.should_commit == 'true' && needs.download_artifacts.outputs.last_version_classic != '' && needs.download_artifacts.outputs.last_version_modern != '')
223
env:
224
CURRENT_VERSION_CLASSIC: ${{ needs.download_artifacts.outputs.current_version_classic }}
225
CURRENT_VERSION_MODERN: ${{ needs.download_artifacts.outputs.current_version_modern }}
@@ -230,12 +236,12 @@ jobs:
236
grep -rl "$LAST_VERSION_MODERN" ./compiled | xargs -r sed -i -e "s/$LAST_VERSION_MODERN/$CURRENT_VERSION_MODERN/g"
237
grep -rl "$LAST_VERSION_MODERN" ./compiled || echo "Classic version re-applied"
238
- name: Will commit these changes
233
- if: steps.check_should_commit.outputs.should_commit == 'true'
239
+ if: inputs.force || steps.check_should_commit.outputs.should_commit == 'true'
240
run: |
241
echo ":"
242
git status -u
243
- name: Commit changes to branch
238
- if: steps.check_should_commit.outputs.should_commit == 'true'
244
+ if: inputs.force || steps.check_should_commit.outputs.should_commit == 'true'
245
uses: stefanzweifel/git-auto-commit-action@v4
246
with:
247
commit_message: |
@@ -272,6 +278,7 @@ jobs:
278
grep -rl "$CURRENT_VERSION" ./compiled-rn | xargs -r sed -i -e "s/$CURRENT_VERSION/$LAST_VERSION/g"
279
grep -rl "$CURRENT_VERSION" ./compiled-rn || echo "Version reverted"
280
- name: Check for changes
281
+ if: !inputs.force
282
id: check_should_commit
283
run: |
284
echo "Full git status"
@@ -290,7 +297,7 @@ jobs:
297
echo "should_commit=false" >> "$GITHUB_OUTPUT"
298
fi
299
- name: Re-apply version changes
293
- if: steps.check_should_commit.outputs.should_commit == 'true' && needs.download_artifacts.outputs.last_version_rn != ''
300
+ if: inputs.force || (steps.check_should_commit.outputs.should_commit == 'true' && needs.download_artifacts.outputs.last_version_rn != '')
301
env:
302
CURRENT_VERSION: ${{ needs.download_artifacts.outputs.current_version_rn }}
303
LAST_VERSION: ${{ needs.download_artifacts.outputs.last_version_rn }}
@@ -300,12 +307,12 @@ jobs:
307
grep -rl "$LAST_VERSION" ./compiled-rn | xargs -r sed -i -e "s/$LAST_VERSION/$CURRENT_VERSION/g"
308
grep -rl "$LAST_VERSION" ./compiled-rn || echo "Version re-applied"
309
- name: Add files for signing
303
- if: steps.check_should_commit.outputs.should_commit == 'true'
310
+ if: inputs.force || steps.check_should_commit.outputs.should_commit == 'true'
311
run: |
312
echo ":"
313
git add .
314
- name: Signing files
308
- if: steps.check_should_commit.outputs.should_commit == 'true'
315
+ if: inputs.force || steps.check_should_commit.outputs.should_commit == 'true'
316
uses: actions/github-script@v7
317
with:
318
script: |
@@ -388,12 +395,12 @@ jobs:
395
console.error('Error signing files:', e);
396
}
397
- name: Will commit these changes
391
- if: steps.check_should_commit.outputs.should_commit == 'true'
398
+ if: inputs.force || steps.check_should_commit.outputs.should_commit == 'true'
399
run: |
400
git add .
401
git status
402
- name: Commit changes to branch
396
- if: steps.check_should_commit.outputs.should_commit == 'true'
403
+ if: inputs.force || steps.check_should_commit.outputs.should_commit == 'true'
404
uses: stefanzweifel/git-auto-commit-action@v4
405
with:
406
commit_message: |