Commit Queue #21503
This file contains 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 requires the following secrets to be set on the repository: | |
# GH_USER_NAME: GitHub user whose Jenkins and GitHub token are defined below | |
# GH_USER_TOKEN: GitHub user token, to be used by ncu and to push changes | |
# JENKINS_TOKEN: Jenkins token, to be used to check CI status | |
name: Commit Queue | |
on: | |
# `schedule` event is used instead of `pull_request` because when a | |
# `pull_request` event is triggered on a PR from a fork, GITHUB_TOKEN will | |
# be read-only, and the Action won't have access to any other repository | |
# secrets, which it needs to access Jenkins API. | |
schedule: | |
- cron: "*/5 * * * *" | |
jobs: | |
commitQueue: | |
if: github.repository == 'nodejs/node' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
# A personal token is required because pushing with GITHUB_TOKEN will | |
# prevent commits from running CI after they land on master. It needs | |
# to be set here because `checkout` configures GitHub authentication | |
# for push as well. | |
token: ${{ secrets.GH_USER_TOKEN }} | |
# Install dependencies | |
- name: Install Node.js | |
uses: actions/setup-node@v2-beta | |
with: | |
node-version: '12' | |
- name: Install dependencies | |
run: | | |
sudo apt-get install jq -y | |
npm install -g node-core-utils@latest | |
- name: Set variables | |
run: | | |
echo "::set-env name=REPOSITORY::$(echo ${{ github.repository }} | cut -d/ -f2)" | |
echo "::set-env name=OWNER::${{ github.repository_owner }}" | |
- name: Get Pull Requests | |
uses: octokit/[email protected] | |
id: get_mergable_pull_requests | |
with: | |
query: | | |
query release($owner:String!,$repo:String!, $base_ref:String!) { | |
repository(owner:$owner, name:$repo) { | |
pullRequests(baseRefName: $base_ref, labels: ["commit-queue"], states: OPEN, last: 100) { | |
nodes { | |
number | |
} | |
} | |
} | |
} | |
owner: ${{ env.OWNER }} | |
repo: ${{ env.REPOSITORY }} | |
# Commit queue is only enabled for the default branch on the repository | |
# TODO(mmarchini): get the default branch programmatically instead of | |
# assuming `master` | |
base_ref: "master" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Configure node-core-utils | |
run: | | |
ncu-config set branch master | |
ncu-config set upstream origin | |
ncu-config set username "${{ secrets.GH_USER_NAME }}" | |
ncu-config set token "${{ secrets.GH_USER_TOKEN }}" | |
ncu-config set jenkins_token "${{ secrets.JENKINS_TOKEN }}" | |
ncu-config set repo "${{ env.REPOSITORY }}" | |
ncu-config set owner "${{ env.OWNER }}" | |
- name: Start the commit queue | |
run: ./tools/actions/commit-queue.sh ${{ env.OWNER }} ${{ env.REPOSITORY }} ${{ secrets.GITHUB_TOKEN }} $(echo '${{ steps.get_mergable_pull_requests.outputs.data }}' | jq '.repository.pullRequests.nodes | map(.number) | .[]') |