diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index cbbe70450c..6f170a723e 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -365,12 +365,24 @@ jobs: !contains(needs.*.result, 'failure') steps: - uses: actions/checkout@v2 + with: + fetch-depth: 0 + ref: ${{ github.event.pull_request.head.ref }} + token: ${{ secrets.TOKEN_RELEASE_BOT }} - name: Restore cache uses: ./.github/actions/cache with: job: cts + - name: Push generated code to generated branch + id: pushGeneratedCode + if: github.event_name == 'pull_request' + run: yarn workspace scripts pushGeneratedCode + env: + GITHUB_TOKEN: ${{ secrets.TOKEN_GENERATE_BOT }} + PR_NUMBER: ${{ github.event.number }} + - name: Check JavaScript client size run: exit $(yarn workspace algoliasearch-client-javascript test:size | echo $?) @@ -385,7 +397,7 @@ jobs: - name: Run run: yarn cli cts run - codegen: + codegen_on_main: runs-on: ubuntu-20.04 timeout-minutes: 10 needs: @@ -394,6 +406,7 @@ jobs: - client_javascript_algoliasearch if: | always() && + github.event_name == 'refs/heads/main' && needs.setup.outputs.RUN_CODEGEN == 'true' && needs.cts.result == 'success' steps: @@ -408,17 +421,14 @@ jobs: with: job: codegen - - name: Push generated code + - name: Push generated code to main id: pushGeneratedCode run: yarn workspace scripts pushGeneratedCode env: GITHUB_TOKEN: ${{ secrets.TOKEN_GENERATE_BOT }} - PR_NUMBER: ${{ github.event.number }} - name: Spread generation to each repository - if: | - steps.pushGeneratedCode.exitcode == 0 && - github.ref == 'refs/heads/main' + if: steps.pushGeneratedCode.exitcode == 0 run: yarn workspace scripts spreadGeneration env: GITHUB_TOKEN: ${{ secrets.TOKEN_RELEASE_BOT }}