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
Refs: #40985 (comment)

PR-URL: #41193
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
aduh95 authored and danielleadams committed Jan 31, 2022
1 parent 4916f08 commit 4bc5efe
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 14 deletions.
24 changes: 20 additions & 4 deletions .github/workflows/auto-start-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,27 @@ env:
NODE_VERSION: lts/*

jobs:
startCI:
get_prs_for_ci:
if: github.repository == 'nodejs/node'
runs-on: ubuntu-latest
outputs:
numbers: ${{ steps.get_prs_for_ci.outputs.numbers }}
steps:
- name: Get Pull Requests
id: get_prs_for_ci
run: >
gh pr list \
--repo ${{ github.repository }} \
--label 'request-ci' \
--json 'number' \
-t '::set-output name=numbers::{{ range . }}{{ .number }} {{ end }}' \
--limit 100
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
startCI:
needs: get_prs_for_ci
if: needs.get_prs_for_ci.outputs.numbers != ''
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
Expand All @@ -37,8 +55,6 @@ 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"
run: ./tools/actions/start-ci.sh "${{ needs.get_prs_for_ci.outputs.numbers }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32 changes: 22 additions & 10 deletions .github/workflows/commit-queue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,28 @@ env:
NODE_VERSION: lts/*

jobs:
commitQueue:
get_mergeable_prs:
if: github.repository == 'nodejs/node'
runs-on: ubuntu-latest
outputs:
numbers: ${{ steps.get_mergeable_prs.outputs.numbers }}
steps:
- name: Get Pull Requests
id: get_mergeable_prs
run: >
gh pr list \
--repo ${{ github.repository }} \
--base ${{ github.ref_name }} \
--label 'commit-queue' \
--json 'number' \
-t '::set-output name=numbers::{{ range . }}{{ .number }} {{ end }}' \
--limit 100
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
commitQueue:
needs: get_mergeable_prs
if: needs.get_mergeable_prs.outputs.numbers != ''
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
Expand All @@ -44,11 +63,10 @@ jobs:
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
run: |
ncu-config set branch ${DEFAULT_BRANCH}
ncu-config set branch ${GITHUB_REF_NAME}
ncu-config set upstream origin
ncu-config set username "${{ secrets.GH_USER_NAME }}"
ncu-config set token "${{ secrets.GH_USER_TOKEN }}"
Expand All @@ -57,12 +75,6 @@ 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"
run: ./tools/actions/commit-queue.sh ${{ env.OWNER }} ${{ env.REPOSITORY }} "${{ needs.get_mergeable_prs.outputs.numbers }}"
env:
GITHUB_TOKEN: ${{ secrets.GH_USER_TOKEN }}

0 comments on commit 4bc5efe

Please sign in to comment.