Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
MoLow committed Nov 10, 2022
1 parent 03fb789 commit 06d59da
Showing 1 changed file with 61 additions and 40 deletions.
101 changes: 61 additions & 40 deletions .github/workflows/commit-queue.yml
Expand Up @@ -10,8 +10,10 @@ on:
# `pull_request` event is triggered on a PR from a fork, GITHUB_TOKEN will
# be read-only, and the Action won't have access to any other repository
# secrets, which it needs to access Jenkins API.
schedule:
- cron: '*/5 * * * *'
# schedule:
# - cron: '*/5 * * * *'
workflow_dispatch:


concurrency: ${{ github.workflow }}

Expand All @@ -25,63 +27,82 @@ jobs:
get_mergeable_prs:
permissions:
pull-requests: read
if: github.repository == 'nodejs/node'
# 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 \
echo 123
date
date --date="2 days ago" +"%Y-%m-%dT%H:%M:%S%z"
prs=$(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
--search "created:<=$(date --date="2 days ago" +"%Y-%m-%dT%H:%M:%S%z")" \
-t '{{ range . }}{{ .number }} {{ end }}' \
--limit 100)
fast_track_prs=$(gh pr list \
--repo ${{ github.repository }} \
--base ${{ github.ref_name }} \
--label 'commit-queue' \
--label 'fast-track' \
--json 'number' \
-t '{{ range . }}{{ .number }} {{ end }}' \
--limit 100)
numbers=$(echo $prs' '$fast_track_prs | jq -r -s 'unique | join(" ")')
echo $prs
echo $fast_track_prs
echo $numbers
echo $(date --date="2 days ago" +"%Y-%m-%dT%H:%M:%S%z")
echo "numbers=$numbers" >> $GITHUB_OUTPUT
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@v3
with:
# Needs the whole git history for ncu to work
# See https://github.com/nodejs/node-core-utils/pull/486
fetch-depth: 0
# A personal token is required because pushing with GITHUB_TOKEN will
# prevent commits from running CI after they land. It needs
# to be set here because `checkout` configures GitHub authentication
# for push as well.
token: ${{ secrets.GH_USER_TOKEN }}
- run: echo ${{ needs.get_mergeable_prs.outputs.numbers }}
# - uses: actions/checkout@v3
# with:
# # Needs the whole git history for ncu to work
# # See https://github.com/nodejs/node-core-utils/pull/486
# fetch-depth: 0
# # A personal token is required because pushing with GITHUB_TOKEN will
# # prevent commits from running CI after they land. It needs
# # to be set here because `checkout` configures GitHub authentication
# # for push as well.
# token: ${{ secrets.GH_USER_TOKEN }}

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

- name: Set variables
run: |
echo "REPOSITORY=$(echo ${{ github.repository }} | cut -d/ -f2)" >> $GITHUB_ENV
echo "OWNER=${{ github.repository_owner }}" >> $GITHUB_ENV
# - name: Set variables
# run: |
# echo "REPOSITORY=$(echo ${{ github.repository }} | cut -d/ -f2)" >> $GITHUB_ENV
# echo "OWNER=${{ github.repository_owner }}" >> $GITHUB_ENV

- name: Configure node-core-utils
run: |
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 }}"
ncu-config set jenkins_token "${{ secrets.JENKINS_TOKEN }}"
ncu-config set repo "${REPOSITORY}"
ncu-config set owner "${OWNER}"
# - name: Configure node-core-utils
# run: |
# 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 }}"
# ncu-config set jenkins_token "${{ secrets.JENKINS_TOKEN }}"
# ncu-config set repo "${REPOSITORY}"
# ncu-config set owner "${OWNER}"

- name: Start the Commit Queue
run: ./tools/actions/commit-queue.sh ${{ env.OWNER }} ${{ env.REPOSITORY }} ${{ needs.get_mergeable_prs.outputs.numbers }}
env:
GITHUB_TOKEN: ${{ secrets.GH_USER_TOKEN }}
# - name: Start the Commit Queue
# 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 06d59da

Please sign in to comment.