Skip to content

Commit

Permalink
tools: fix `GitHub actions status when CQ is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
aduh95 committed Dec 16, 2021
1 parent 13ee108 commit 14cf6bf
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 10 deletions.
19 changes: 16 additions & 3 deletions .github/workflows/auto-start-ci.yml
Expand Up @@ -16,19 +16,33 @@ jobs:
if: github.repository == 'nodejs/node'
runs-on: ubuntu-latest
steps:
- name: Get Pull Requests
continue_on_error: true
id: get_prs_for_ci
run: gh pr list \
--repo ${{ github.repository }} \
--base ${{ env.DEFAULT_BRANCH }} \
--label 'request-ci' \
--json 'number' \
-t '::set-output name=numbers::{{ range . }}{{ .number }} {{ end }}' \
--limit 100
- uses: actions/checkout@v2
if: ${{ success() }}
with:
persist-credentials: false

# Install dependencies
- name: Install Node.js
if: ${{ success() }}
uses: actions/setup-node@v2
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install node-core-utils
if: ${{ success() }}
run: npm install -g node-core-utils

- name: Setup node-core-utils
if: ${{ success() }}
run: |
ncu-config set username ${{ secrets.JENKINS_USER }}
ncu-config set token none
Expand All @@ -37,8 +51,7 @@ jobs:
ncu-config set repo "$(echo ${{ github.repository }} | cut -d/ -f2)"
- name: Start the CI
run: |
PRs=$(gh pr list --label 'request-ci' --json number --jq 'map(.number) | .[]' --limit 100)
./tools/actions/start-ci.sh "$PRs"
if: ${{ success() }}
run: ./tools/actions/start-ci.sh "${{ steps.get_prs_for_ci.outputs.numbers }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23 changes: 16 additions & 7 deletions .github/workflows/commit-queue.yml
Expand Up @@ -21,7 +21,18 @@ jobs:
if: github.repository == 'nodejs/node'
runs-on: ubuntu-latest
steps:
- name: Get Pull Requests
continue_on_error: true
id: get_mergable_pull_requests
run: gh pr list \
--repo ${{ github.repository }} \
--base ${{ env.DEFAULT_BRANCH }} \
--label 'commit-queue' \
--json 'number' \
-t '::set-output name=numbers::{{ range . }}{{ .number }} {{ end }}' \
--limit 100
- uses: actions/checkout@v2
if: ${{ success() }}
with:
# Needs the whole git history for ncu to work
# See https://github.com/nodejs/node-core-utils/pull/486
Expand All @@ -34,19 +45,22 @@ jobs:

# Install dependencies
- name: Install Node.js
if: ${{ success() }}
uses: actions/setup-node@v2
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install node-core-utils
run: npm install -g node-core-utils@latest

- name: Set variables
if: ${{ success() }}
run: |
echo "REPOSITORY=$(echo ${{ github.repository }} | cut -d/ -f2)" >> $GITHUB_ENV
echo "OWNER=${{ github.repository_owner }}" >> $GITHUB_ENV
echo "DEFAULT_BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
- name: Configure node-core-utils
if: ${{ success() }}
run: |
ncu-config set branch ${DEFAULT_BRANCH}
ncu-config set upstream origin
Expand All @@ -57,12 +71,7 @@ jobs:
ncu-config set owner "${OWNER}"
- name: Start the Commit Queue
run: |
PRs=$(gh pr list \
--base ${{ env.DEFAULT_BRANCH }} \
--label 'commit-queue' \
--json number --jq 'map(.number) | .[]' \
--limit 100)
./tools/actions/commit-queue.sh ${{ env.OWNER }} ${{ env.REPOSITORY }} "$PRs"
if: ${{ success() }}
run: ./tools/actions/commit-queue.sh ${{ env.OWNER }} ${{ env.REPOSITORY }} "${{ steps.get_mergable_pull_requests.outputs.numbers }}"
env:
GITHUB_TOKEN: ${{ secrets.GH_USER_TOKEN }}

0 comments on commit 14cf6bf

Please sign in to comment.