From abf39d1911128cfb63cdcce05f36589f6eee3c00 Mon Sep 17 00:00:00 2001 From: Mary Marchini Date: Mon, 10 Aug 2020 00:11:06 -0700 Subject: [PATCH] build: use pull_request_target to start Jenkins GitHub recently introduced a new Pull Request event for Actions with access to Secrets and GITHUB_TOKEN with write access. Therefore, we don't need to use the scheduler event to start Jenkins anymore. Ref: https://github.blog/2020-08-03-github-actions-improvements-for-fork-and-pull-request-workflows/ --- .github/workflows/auto-start-ci.yml | 39 +++++------------------------ 1 file changed, 6 insertions(+), 33 deletions(-) diff --git a/.github/workflows/auto-start-ci.yml b/.github/workflows/auto-start-ci.yml index 0bc9e7c1c65fc2..95eb03f6fa9da1 100644 --- a/.github/workflows/auto-start-ci.yml +++ b/.github/workflows/auto-start-ci.yml @@ -2,25 +2,18 @@ name: Auto Start CI on: - schedule: - # `schedule` event is used instead of `pull_request` because when a - # `pull_requesst` 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. Runs every five minutes - # (fastest the scheduler can run). Five minutes is optimistic, it can take - # longer to run. - - cron: "*/5 * * * *" + pull_request_target: + types: + - labeled jobs: startCI: - if: github.repository == 'nodejs/node' runs-on: ubuntu-latest + if: github.event.label.name == 'request-ci' steps: - - uses: actions/checkout@master + - uses: actions/checkout@v2 # Install dependencies - - name: Install jq - run: sudo apt-get install jq -y - name: Install Node.js uses: actions/setup-node@v2-beta with: @@ -33,26 +26,6 @@ jobs: echo "::set-env name=REPOSITORY::$(echo ${{ github.repository }} | cut -d/ -f2)" echo "::set-env name=OWNER::${{ github.repository_owner }}" - # Get Pull Requests - - name: Get Pull Requests - uses: octokit/graphql-action@v2.x - id: get_prs_for_ci - with: - query: | - query prs($owner:String!, $repo:String!) { - repository(owner:$owner, name:$repo) { - pullRequests(labels: ["request-ci"], states: OPEN, last: 100) { - nodes { - number - } - } - } - } - owner: ${{ env.OWNER }} - repo: ${{ env.REPOSITORY }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Setup node-core-utils run: | ncu-config set username ${{ secrets.JENKINS_USER }} @@ -62,4 +35,4 @@ jobs: ncu-config set repo ${{ env.REPOSITORY }} - name: Start CI - run: ./tools/actions/start-ci.sh ${{ secrets.GITHUB_TOKEN }} ${{ env.OWNER }} ${{ env.REPOSITORY }} $(echo '${{ steps.get_prs_for_ci.outputs.data }}' | jq '.repository.pullRequests.nodes | map(.number) | .[]') + run: ./tools/actions/start-ci.sh ${{ secrets.GITHUB_TOKEN }} ${{ env.OWNER }} ${{ env.REPOSITORY }} ${{ github.event.number }}