Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools: fix `GitHub actions status when CQ is empty #41193

Merged
merged 1 commit into from Dec 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 20 additions & 4 deletions .github/workflows/auto-start-ci.yml
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
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 }}