mirror of
https://github.com/nodejs/node.git
synced 2026-10-28 18:25:13 +08:00
The workflow run metadata query in node-core-utils requires Actions read permission for GITHUB_TOKEN. Grant it to the commit queue and automatic CI jobs. Refs: https://github.com/nodejs/node-core-utils/pull/1192 Signed-off-by: Filip Skokan <panva.ip@gmail.com> PR-URL: https://github.com/nodejs/node/pull/66919 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Mike McCready <66998419+MikeMcC399@users.noreply.github.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Tierney Cyren <hello@bnb.im> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
95 lines
3.3 KiB
YAML
95 lines
3.3 KiB
YAML
# 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 or resume CI
|
|
# Optional repository variables:
|
|
# AUTO_START_CI_BATCH_SIZE: maximum PRs to process per run (default: 5)
|
|
# AUTO_START_CI_MAX_WORKLOAD: pause at this many running or queued PR jobs (default: 15)
|
|
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: 3/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
|
|
# Explicit bash enables pipefail so jq cannot hide a failed gh query.
|
|
shell: bash
|
|
run: |
|
|
if ! [[ "$BATCH_SIZE" =~ ^[1-9][0-9]*$ ]]; then
|
|
echo '::error::AUTO_START_CI_BATCH_SIZE must be a strictly positive integer'
|
|
exit 1
|
|
fi
|
|
# Filter before selecting the batch; UNKNOWN mergeability is retried later.
|
|
numbers=$(gh pr list \
|
|
--repo "$GITHUB_REPOSITORY" \
|
|
--json 'number,mergeable' \
|
|
--search 'review:approved label:request-ci,resume-ci' \
|
|
--limit 100 \
|
|
| jq --argjson limit "$BATCH_SIZE" \
|
|
'[.[] | select(.mergeable == "MERGEABLE") | .number] | .[:$limit] | map(tostring) | join(" ")' -r)
|
|
echo "numbers=$numbers" >> "$GITHUB_OUTPUT"
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
BATCH_SIZE: ${{ vars.AUTO_START_CI_BATCH_SIZE || '5' }}
|
|
start-ci:
|
|
permissions:
|
|
actions: read
|
|
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@820762786026740c76f36085b0efc47a31fe5020 # v7.0.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 or resume the CI
|
|
run: |
|
|
read -r -a numbers <<< "$PULL_REQUESTS"
|
|
curl -fsSL "https://github.com/${GITHUB_REPOSITORY}/raw/${GITHUB_SHA}/tools/actions/start-ci.sh" \
|
|
| sh -s -- "${numbers[@]}"
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
PULL_REQUESTS: ${{ needs.get-prs-for-ci.outputs.numbers }}
|
|
MAX_WORKLOAD: ${{ vars.AUTO_START_CI_MAX_WORKLOAD || '15' }}
|