Skip to content

Commit 4708fb9

Browse files
committed
Fix runtime_commit_artifacts workflow
I messed up the yml syntax and also realized that our script doesn't currently handle renames or deletes, so I fixed that ghstack-source-id: 7d481a951abaabd1a2985c8959d8acb7103ed12e Pull Request resolved: #31028
1 parent 5b19dc0 commit 4708fb9

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed

.github/workflows/runtime_commit_artifacts.yml

+22-14
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ jobs:
171171

172172
commit_www_artifacts:
173173
needs: download_artifacts
174-
if: ${{ (github.ref == 'refs/heads/main' && needs.download_artifacts.outputs.www_branch_count == '0') || github.ref == 'refs/heads/meta-www' }}
174+
if: inputs.force == true || (github.ref == 'refs/heads/main' && needs.download_artifacts.outputs.www_branch_count == '0')
175175
runs-on: ubuntu-latest
176176
steps:
177177
- uses: actions/checkout@v4
@@ -201,7 +201,7 @@ jobs:
201201
grep -rl "$CURRENT_VERSION_MODERN" ./compiled | xargs -r sed -i -e "s/$CURRENT_VERSION_MODERN/$LAST_VERSION_MODERN/g"
202202
grep -rl "$CURRENT_VERSION_MODERN" ./compiled || echo "Modern version reverted"
203203
- name: Check for changes
204-
if: !inputs.force
204+
if: inputs.force != true
205205
id: check_should_commit
206206
run: |
207207
echo "Full git status"
@@ -219,7 +219,7 @@ jobs:
219219
echo "should_commit=false" >> "$GITHUB_OUTPUT"
220220
fi
221221
- name: Re-apply version changes
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 != '')
222+
if: inputs.force == true || (steps.check_should_commit.outputs.should_commit == 'true' && needs.download_artifacts.outputs.last_version_classic != '' && needs.download_artifacts.outputs.last_version_modern != '')
223223
env:
224224
CURRENT_VERSION_CLASSIC: ${{ needs.download_artifacts.outputs.current_version_classic }}
225225
CURRENT_VERSION_MODERN: ${{ needs.download_artifacts.outputs.current_version_modern }}
@@ -236,12 +236,12 @@ jobs:
236236
grep -rl "$LAST_VERSION_MODERN" ./compiled | xargs -r sed -i -e "s/$LAST_VERSION_MODERN/$CURRENT_VERSION_MODERN/g"
237237
grep -rl "$LAST_VERSION_MODERN" ./compiled || echo "Classic version re-applied"
238238
- name: Will commit these changes
239-
if: inputs.force || steps.check_should_commit.outputs.should_commit == 'true'
239+
if: inputs.force == true || steps.check_should_commit.outputs.should_commit == 'true'
240240
run: |
241241
echo ":"
242242
git status -u
243243
- name: Commit changes to branch
244-
if: inputs.force || steps.check_should_commit.outputs.should_commit == 'true'
244+
if: inputs.force == true || steps.check_should_commit.outputs.should_commit == 'true'
245245
uses: stefanzweifel/git-auto-commit-action@v4
246246
with:
247247
commit_message: |
@@ -255,7 +255,7 @@ jobs:
255255

256256
commit_fbsource_artifacts:
257257
needs: download_artifacts
258-
if: ${{ (github.ref == 'refs/heads/main' && needs.download_artifacts.outputs.fbsource_branch_count == '0') || github.ref == 'refs/heads/meta-fbsource' }}
258+
if: inputs.force == true || (github.ref == 'refs/heads/main' && needs.download_artifacts.outputs.fbsource_branch_count == '0')
259259
runs-on: ubuntu-latest
260260
steps:
261261
- uses: actions/checkout@v4
@@ -278,7 +278,7 @@ jobs:
278278
grep -rl "$CURRENT_VERSION" ./compiled-rn | xargs -r sed -i -e "s/$CURRENT_VERSION/$LAST_VERSION/g"
279279
grep -rl "$CURRENT_VERSION" ./compiled-rn || echo "Version reverted"
280280
- name: Check for changes
281-
if: !inputs.force
281+
if: inputs.force != 'true'
282282
id: check_should_commit
283283
run: |
284284
echo "Full git status"
@@ -297,7 +297,7 @@ jobs:
297297
echo "should_commit=false" >> "$GITHUB_OUTPUT"
298298
fi
299299
- name: Re-apply version changes
300-
if: inputs.force || (steps.check_should_commit.outputs.should_commit == 'true' && needs.download_artifacts.outputs.last_version_rn != '')
300+
if: inputs.force == true || (steps.check_should_commit.outputs.should_commit == 'true' && needs.download_artifacts.outputs.last_version_rn != '')
301301
env:
302302
CURRENT_VERSION: ${{ needs.download_artifacts.outputs.current_version_rn }}
303303
LAST_VERSION: ${{ needs.download_artifacts.outputs.last_version_rn }}
@@ -307,12 +307,12 @@ jobs:
307307
grep -rl "$LAST_VERSION" ./compiled-rn | xargs -r sed -i -e "s/$LAST_VERSION/$CURRENT_VERSION/g"
308308
grep -rl "$LAST_VERSION" ./compiled-rn || echo "Version re-applied"
309309
- name: Add files for signing
310-
if: inputs.force || steps.check_should_commit.outputs.should_commit == 'true'
310+
if: inputs.force == true || steps.check_should_commit.outputs.should_commit == 'true'
311311
run: |
312312
echo ":"
313313
git add .
314314
- name: Signing files
315-
if: inputs.force || steps.check_should_commit.outputs.should_commit == 'true'
315+
if: inputs.force == true || steps.check_should_commit.outputs.should_commit == 'true'
316316
uses: actions/github-script@v7
317317
with:
318318
script: |
@@ -366,8 +366,9 @@ jobs:
366366
console.log('Signing files in directory:', directory);
367367
try {
368368
const result = execSync(`git status --porcelain ${directory}`, {encoding: 'utf8'});
369+
console.log(result);
369370
370-
// Parse the git status output to get file paths
371+
// Parse the git status output to get file paths!
371372
const files = result.split('\n').filter(file => file.endsWith('.js'));
372373
373374
if (files.length === 0) {
@@ -376,7 +377,14 @@ jobs:
376377
);
377378
} else {
378379
files.forEach(line => {
379-
const file = line.slice(3).trim();
380+
let file = null;
381+
if (line.startsWith('D ')) {
382+
return;
383+
} else if (line.startsWith('R ')) {
384+
file = line.slice(line.indexOf('->') + 3);
385+
} else {
386+
file = line.slice(3).trim();
387+
}
380388
if (file) {
381389
console.log(' Signing file:', file);
382390
const originalContents = fs.readFileSync(file, 'utf8');
@@ -395,12 +403,12 @@ jobs:
395403
console.error('Error signing files:', e);
396404
}
397405
- name: Will commit these changes
398-
if: inputs.force || steps.check_should_commit.outputs.should_commit == 'true'
406+
if: inputs.force == true || steps.check_should_commit.outputs.should_commit == 'true'
399407
run: |
400408
git add .
401409
git status
402410
- name: Commit changes to branch
403-
if: inputs.force || steps.check_should_commit.outputs.should_commit == 'true'
411+
if: inputs.force == true || steps.check_should_commit.outputs.should_commit == 'true'
404412
uses: stefanzweifel/git-auto-commit-action@v4
405413
with:
406414
commit_message: |

0 commit comments

Comments
 (0)