1--- 2# This action requires the following secrets to be set on the repository: 3# GH_USER_NAME: GitHub user whose Jenkins and GitHub token are defined below 4# GH_USER_TOKEN: GitHub user token, to be used by ncu and to push changes 5# JENKINS_TOKEN: Jenkins token, to be used to check CI status 6 7name: Commit Queue 8 9on: 10 # `schedule` event is used instead of `pull_request` because when a 11 # `pull_request` event is triggered on a PR from a fork, GITHUB_TOKEN will 12 # be read-only, and the Action won't have access to any other repository 13 # secrets, which it needs to access Jenkins API. 14 schedule: 15 - cron: "*/5 * * * *" 16 17jobs: 18 commitQueue: 19 if: github.repository == 'nodejs/node' 20 runs-on: ubuntu-latest 21 steps: 22 - uses: actions/checkout@v2 23 with: 24 # A personal token is required because pushing with GITHUB_TOKEN will 25 # prevent commits from running CI after they land on master. It needs 26 # to be set here because `checkout` configures GitHub authentication 27 # for push as well. 28 token: ${{ secrets.GH_USER_TOKEN }} 29 30 # Install dependencies 31 - name: Install Node.js 32 uses: actions/setup-node@v2-beta 33 with: 34 node-version: '12' 35 - name: Install dependencies 36 run: | 37 sudo apt-get install jq -y 38 npm install -g node-core-utils@latest 39 40 - name: Set variables 41 run: | 42 echo "::set-env name=REPOSITORY::$(echo ${{ github.repository }} | cut -d/ -f2)" 43 echo "::set-env name=OWNER::${{ github.repository_owner }}" 44 45 - name: Get Pull Requests 46 uses: octokit/graphql-action@v2.x 47 id: get_mergable_pull_requests 48 with: 49 query: | 50 query release($owner:String!,$repo:String!, $base_ref:String!) { 51 repository(owner:$owner, name:$repo) { 52 pullRequests(baseRefName: $base_ref, labels: ["commit-queue"], states: OPEN, last: 100) { 53 nodes { 54 number 55 } 56 } 57 } 58 } 59 owner: ${{ env.OWNER }} 60 repo: ${{ env.REPOSITORY }} 61 # Commit queue is only enabled for the default branch on the repository 62 # TODO(mmarchini): get the default branch programmatically instead of 63 # assuming `master` 64 base_ref: "master" 65 env: 66 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 67 68 - name: Configure node-core-utils 69 run: | 70 ncu-config set branch master 71 ncu-config set upstream origin 72 ncu-config set username "${{ secrets.GH_USER_NAME }}" 73 ncu-config set token "${{ secrets.GH_USER_TOKEN }}" 74 ncu-config set jenkins_token "${{ secrets.JENKINS_TOKEN }}" 75 ncu-config set repo "${{ env.REPOSITORY }}" 76 ncu-config set owner "${{ env.OWNER }}" 77 78 - name: Start the commit queue 79 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) | .[]') 80