Skip to content

Commit 467afcb

Browse files
authored
chore(ci): push generated code before cts (#382)
1 parent 5516b56 commit 467afcb

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

.github/workflows/check.yml

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -365,12 +365,24 @@ jobs:
365365
!contains(needs.*.result, 'failure')
366366
steps:
367367
- uses: actions/checkout@v2
368+
with:
369+
fetch-depth: 0
370+
ref: ${{ github.event.pull_request.head.ref }}
371+
token: ${{ secrets.TOKEN_RELEASE_BOT }}
368372

369373
- name: Restore cache
370374
uses: ./.github/actions/cache
371375
with:
372376
job: cts
373377

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+
374386
- name: Check JavaScript client size
375387
run: exit $(yarn workspace algoliasearch-client-javascript test:size | echo $?)
376388

@@ -385,7 +397,7 @@ jobs:
385397
- name: Run
386398
run: yarn cli cts run
387399

388-
codegen:
400+
codegen_on_main:
389401
runs-on: ubuntu-20.04
390402
timeout-minutes: 10
391403
needs:
@@ -394,6 +406,7 @@ jobs:
394406
- client_javascript_algoliasearch
395407
if: |
396408
always() &&
409+
github.event_name == 'refs/heads/main' &&
397410
needs.setup.outputs.RUN_CODEGEN == 'true' &&
398411
needs.cts.result == 'success'
399412
steps:
@@ -408,17 +421,14 @@ jobs:
408421
with:
409422
job: codegen
410423

411-
- name: Push generated code
424+
- name: Push generated code to main
412425
id: pushGeneratedCode
413426
run: yarn workspace scripts pushGeneratedCode
414427
env:
415428
GITHUB_TOKEN: ${{ secrets.TOKEN_GENERATE_BOT }}
416-
PR_NUMBER: ${{ github.event.number }}
417429

418430
- 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
422432
run: yarn workspace scripts spreadGeneration
423433
env:
424434
GITHUB_TOKEN: ${{ secrets.TOKEN_RELEASE_BOT }}

0 commit comments

Comments
 (0)