@@ -365,12 +365,24 @@ jobs:
365
365
!contains(needs.*.result, 'failure')
366
366
steps :
367
367
- uses : actions/checkout@v2
368
+ with :
369
+ fetch-depth : 0
370
+ ref : ${{ github.event.pull_request.head.ref }}
371
+ token : ${{ secrets.TOKEN_RELEASE_BOT }}
368
372
369
373
- name : Restore cache
370
374
uses : ./.github/actions/cache
371
375
with :
372
376
job : cts
373
377
378
+ - name : Push generated code to generated branch
379
+ id : pushGeneratedCode
380
+ if : github.event_name == 'pull_request'
381
+ run : yarn workspace scripts pushGeneratedCode
382
+ env :
383
+ GITHUB_TOKEN : ${{ secrets.TOKEN_GENERATE_BOT }}
384
+ PR_NUMBER : ${{ github.event.number }}
385
+
374
386
- name : Check JavaScript client size
375
387
run : exit $(yarn workspace algoliasearch-client-javascript test:size | echo $?)
376
388
@@ -385,7 +397,7 @@ jobs:
385
397
- name : Run
386
398
run : yarn cli cts run
387
399
388
- codegen :
400
+ codegen_on_main :
389
401
runs-on : ubuntu-20.04
390
402
timeout-minutes : 10
391
403
needs :
@@ -394,6 +406,7 @@ jobs:
394
406
- client_javascript_algoliasearch
395
407
if : |
396
408
always() &&
409
+ github.event_name == 'refs/heads/main' &&
397
410
needs.setup.outputs.RUN_CODEGEN == 'true' &&
398
411
needs.cts.result == 'success'
399
412
steps :
@@ -408,17 +421,14 @@ jobs:
408
421
with :
409
422
job : codegen
410
423
411
- - name : Push generated code
424
+ - name : Push generated code to main
412
425
id : pushGeneratedCode
413
426
run : yarn workspace scripts pushGeneratedCode
414
427
env :
415
428
GITHUB_TOKEN : ${{ secrets.TOKEN_GENERATE_BOT }}
416
- PR_NUMBER : ${{ github.event.number }}
417
429
418
430
- name : Spread generation to each repository
419
- if : |
420
- steps.pushGeneratedCode.exitcode == 0 &&
421
- github.ref == 'refs/heads/main'
431
+ if : steps.pushGeneratedCode.exitcode == 0
422
432
run : yarn workspace scripts spreadGeneration
423
433
env :
424
434
GITHUB_TOKEN : ${{ secrets.TOKEN_RELEASE_BOT }}
0 commit comments