Auto Start CI #254528
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This action uses the following secrets: | |
| # JENKINS_USER: GitHub user whose Jenkins token is defined below | |
| # JENKINS_TOKEN: Jenkins token, to be used to start CI | |
| name: Auto Start CI | |
| on: | |
| schedule: | |
| # Runs every five minutes (fastest the scheduler can run). Five minutes is | |
| # optimistic, it can take longer to run. | |
| # To understand why `schedule` is used instead of other events, refer to | |
| # ./doc/contributing/commit-queue.md | |
| - cron: '*/5 * * * *' | |
| concurrency: ${{ github.workflow }} | |
| env: | |
| NODE_VERSION: lts/* | |
| permissions: | |
| contents: read | |
| jobs: | |
| get-prs-for-ci: | |
| permissions: | |
| pull-requests: read | |
| if: github.repository == 'nodejs/node' | |
| runs-on: ubuntu-slim | |
| outputs: | |
| numbers: ${{ steps.get_prs_for_ci.outputs.numbers }} | |
| steps: | |
| - name: Get Pull Requests | |
| id: get_prs_for_ci | |
| run: > | |
| echo "numbers=$(gh pr list \ | |
| --repo "$GITHUB_REPOSITORY" \ | |
| --label 'request-ci' \ | |
| --json 'number' \ | |
| --search 'review:approved' \ | |
| -t '{{ range . }}{{ .number }} {{ end }}' \ | |
| --limit 5)" >> "$GITHUB_OUTPUT" | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| start-ci: | |
| permissions: | |
| checks: read | |
| contents: read | |
| pull-requests: write | |
| statuses: read | |
| needs: get-prs-for-ci | |
| if: needs.get-prs-for-ci.outputs.numbers != '' | |
| runs-on: ubuntu-slim | |
| steps: | |
| - name: Install Node.js | |
| uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| - name: Install @node-core/utils | |
| run: npm install -g @node-core/utils | |
| - name: Setup @node-core/utils | |
| run: | | |
| ncu-config set username "$USERNAME" | |
| ncu-config set token "$GH_TOKEN" | |
| ncu-config set jenkins_token "$JENKINS_TOKEN" | |
| ncu-config set owner "$GITHUB_REPOSITORY_OWNER" | |
| ncu-config set repo "${GITHUB_REPOSITORY#*/}" | |
| env: | |
| USERNAME: ${{ secrets.JENKINS_USER }} | |
| GH_TOKEN: ${{ github.token }} | |
| JENKINS_TOKEN: ${{ secrets.JENKINS_TOKEN }} | |
| - name: Start the CI | |
| run: | | |
| curl -fsSL "https://github.com/${GITHUB_REPOSITORY}/raw/${GITHUB_SHA}/tools/actions/start-ci.sh" \ | |
| | sh -s -- ${{ needs.get-prs-for-ci.outputs.numbers }} | |
| env: | |
| GH_TOKEN: ${{ github.token }} |