From e6291678546d36b33b9e4103221ce4f4ba73694e Mon Sep 17 00:00:00 2001 From: Matheus Marchini Date: Sat, 27 Jun 2020 01:55:02 -0700 Subject: [PATCH 1/2] build: add Action to start Jenkins CI Add schedule action which will start Jenkins CI for all Pull Requests labeled as `request-ci`. --- .github/workflows/scheduled.yml | 57 +++++++++++++++++++++++++++++++++ tools/start-ci.sh | 48 +++++++++++++++++++++++++++ 2 files changed, 105 insertions(+) create mode 100644 .github/workflows/scheduled.yml create mode 100644 tools/start-ci.sh diff --git a/.github/workflows/scheduled.yml b/.github/workflows/scheduled.yml new file mode 100644 index 00000000000..8f173512557 --- /dev/null +++ b/.github/workflows/scheduled.yml @@ -0,0 +1,57 @@ +--- +name: Scheduled Actions + +on: + schedule: + - cron: "*/5 * * * *" + +jobs: + commitQueue: + runs-on: ubuntu-latest + steps: + # Install dependencies + - name: Install jq + run: sudo apt-get install jq -y + - name: Install Node.js + uses: actions/setup-node@v2-beta + with: + node-version: '12' + - name: Install node-core-utils + run: npm run -g 'https://github.com/mmarchini/node-core-utils#start-ci' + # run: npm run -g node-core-utils + + - name: Set variables + run: | + 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_mergable_pull_requests + with: + query: | + query release($owner:String!, $repo:String!) { + repository(owner:$owner, name:$repo) { + pullRequests(labels: ["ci-requested"], 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 }} + ncu-config set token none + ncu-config set jenkins_token ${{ secrets.JENKINS_TOKEN }} + ncu-config set owner ${{ env.OWNER }} + ncu-config set repo ${{ env.REPOSITORY }} + + - name: Start CI + run: ./tools/start-ci.sh $(echo '${{ steps.get_mergable_pull_requests.outputs.data }}' | jq '.repository.pullRequests.nodes | map(.number) | .[]') diff --git a/tools/start-ci.sh b/tools/start-ci.sh new file mode 100644 index 00000000000..5b9c114ede3 --- /dev/null +++ b/tools/start-ci.sh @@ -0,0 +1,48 @@ +#!/bin/bash + +set -xe + +REQUEST_CI_LABEL='request-ci' +REQUEST_CI_FAILED_LABEL='request-ci-failed' + +function issueUrl() { + echo "$API_URL/repos/${OWNER}/${REPOSITORY}/issues/${1}" +} + +function labelsUrl() { + echo "$(issueUrl "${1}")/labels" +} + +function commentsUrl() { + echo "$(issueUrl "${1}")/comments" +} + +for pr in "$@"; do + curl -sL --request DELETE \ + --url "$(labelsUrl "$pr")"/"$REQUEST_CI_LABEL" \ + --header "authorization: Bearer ${GITHUB_TOKEN}" \ + --header 'content-type: application/json' + + ci_started=yes + rm -f output; + ncu-ci run "$pr" >output 2>&1 || ci_started=no + + if [ "$ci_started" == "no" ]; then + # Do we need to reset? + curl -sL --request PUT \ + --url "$(labelsUrl "$pr")" \ + --header "authorization: Bearer ${GITHUB_TOKEN}" \ + --header 'content-type: application/json' \ + --data '{"labels": ["'"${REQUEST_CI_FAILED_LABEL}"'"]}' + + jq -n --arg content "
Couldn't start CI
$(cat output)
" '{body: $content}' > output.json + + curl -sL --request POST \ + --url "$(commentsUrl "$pr")" \ + --header "authorization: Bearer ${GITHUB_TOKEN}" \ + --header 'content-type: application/json' \ + --data @output.json + + rm output.json; + fi +done; From 0d0fedabc0975a98cc8b9032d32d19b4a9ba438d Mon Sep 17 00:00:00 2001 From: Matheus Marchini Date: Sat, 27 Jun 2020 01:59:13 -0700 Subject: [PATCH 2/2] doc: empty change 3 --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 92113f2253a..c19dbe9d787 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,7 @@

+ Node.js is an open-source, cross-platform, JavaScript runtime environment. It executes JavaScript code outside of a browser. For more information on using Node.js, see the [Node.js Website][].