Skip to content

Commit 14cf6bf

Browse files
committed
tools: fix `GitHub actions status when CQ is empty
Refs: nodejs#40985 (comment)
1 parent 13ee108 commit 14cf6bf

File tree

2 files changed

+32
-10
lines changed

2 files changed

+32
-10
lines changed

.github/workflows/auto-start-ci.yml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,33 @@ jobs:
1616
if: github.repository == 'nodejs/node'
1717
runs-on: ubuntu-latest
1818
steps:
19+
- name: Get Pull Requests
20+
continue_on_error: true
21+
id: get_prs_for_ci
22+
run: gh pr list \
23+
--repo ${{ github.repository }} \
24+
--base ${{ env.DEFAULT_BRANCH }} \
25+
--label 'request-ci' \
26+
--json 'number' \
27+
-t '::set-output name=numbers::{{ range . }}{{ .number }} {{ end }}' \
28+
--limit 100
1929
- uses: actions/checkout@v2
30+
if: ${{ success() }}
2031
with:
2132
persist-credentials: false
2233

2334
# Install dependencies
2435
- name: Install Node.js
36+
if: ${{ success() }}
2537
uses: actions/setup-node@v2
2638
with:
2739
node-version: ${{ env.NODE_VERSION }}
2840
- name: Install node-core-utils
41+
if: ${{ success() }}
2942
run: npm install -g node-core-utils
3043

3144
- name: Setup node-core-utils
45+
if: ${{ success() }}
3246
run: |
3347
ncu-config set username ${{ secrets.JENKINS_USER }}
3448
ncu-config set token none
@@ -37,8 +51,7 @@ jobs:
3751
ncu-config set repo "$(echo ${{ github.repository }} | cut -d/ -f2)"
3852
3953
- name: Start the CI
40-
run: |
41-
PRs=$(gh pr list --label 'request-ci' --json number --jq 'map(.number) | .[]' --limit 100)
42-
./tools/actions/start-ci.sh "$PRs"
54+
if: ${{ success() }}
55+
run: ./tools/actions/start-ci.sh "${{ steps.get_prs_for_ci.outputs.numbers }}"
4356
env:
4457
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/commit-queue.yml

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,18 @@ jobs:
2121
if: github.repository == 'nodejs/node'
2222
runs-on: ubuntu-latest
2323
steps:
24+
- name: Get Pull Requests
25+
continue_on_error: true
26+
id: get_mergable_pull_requests
27+
run: gh pr list \
28+
--repo ${{ github.repository }} \
29+
--base ${{ env.DEFAULT_BRANCH }} \
30+
--label 'commit-queue' \
31+
--json 'number' \
32+
-t '::set-output name=numbers::{{ range . }}{{ .number }} {{ end }}' \
33+
--limit 100
2434
- uses: actions/checkout@v2
35+
if: ${{ success() }}
2536
with:
2637
# Needs the whole git history for ncu to work
2738
# See https://github.com/nodejs/node-core-utils/pull/486
@@ -34,19 +45,22 @@ jobs:
3445

3546
# Install dependencies
3647
- name: Install Node.js
48+
if: ${{ success() }}
3749
uses: actions/setup-node@v2
3850
with:
3951
node-version: ${{ env.NODE_VERSION }}
4052
- name: Install node-core-utils
4153
run: npm install -g node-core-utils@latest
4254

4355
- name: Set variables
56+
if: ${{ success() }}
4457
run: |
4558
echo "REPOSITORY=$(echo ${{ github.repository }} | cut -d/ -f2)" >> $GITHUB_ENV
4659
echo "OWNER=${{ github.repository_owner }}" >> $GITHUB_ENV
4760
echo "DEFAULT_BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
4861
4962
- name: Configure node-core-utils
63+
if: ${{ success() }}
5064
run: |
5165
ncu-config set branch ${DEFAULT_BRANCH}
5266
ncu-config set upstream origin
@@ -57,12 +71,7 @@ jobs:
5771
ncu-config set owner "${OWNER}"
5872
5973
- name: Start the Commit Queue
60-
run: |
61-
PRs=$(gh pr list \
62-
--base ${{ env.DEFAULT_BRANCH }} \
63-
--label 'commit-queue' \
64-
--json number --jq 'map(.number) | .[]' \
65-
--limit 100)
66-
./tools/actions/commit-queue.sh ${{ env.OWNER }} ${{ env.REPOSITORY }} "$PRs"
74+
if: ${{ success() }}
75+
run: ./tools/actions/commit-queue.sh ${{ env.OWNER }} ${{ env.REPOSITORY }} "${{ steps.get_mergable_pull_requests.outputs.numbers }}"
6776
env:
6877
GITHUB_TOKEN: ${{ secrets.GH_USER_TOKEN }}

0 commit comments

Comments
 (0)