Skip to content

Commit 61c53a6

Browse files
Mesteerydanielleadams
authored andcommittedDec 17, 2021
build: use gh cli in workflows file
PR-URL: #40985 Reviewed-By: Antoine du Hamel <[email protected]>
1 parent 1274a25 commit 61c53a6

File tree

3 files changed

+17
-58
lines changed

3 files changed

+17
-58
lines changed
 

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

+6-29
Original file line numberDiff line numberDiff line change
@@ -28,40 +28,17 @@ jobs:
2828
- name: Install node-core-utils
2929
run: npm install -g node-core-utils
3030

31-
- name: Set variables
32-
run: |
33-
echo "REPOSITORY=$(echo ${{ github.repository }} | cut -d/ -f2)" >> $GITHUB_ENV
34-
echo "OWNER=${{ github.repository_owner }}" >> $GITHUB_ENV
35-
36-
# Get Pull Requests
37-
- name: Get Pull Requests
38-
uses: octokit/graphql-action@v2.x
39-
id: get_prs_for_ci
40-
with:
41-
query: |
42-
query prs($owner:String!, $repo:String!) {
43-
repository(owner:$owner, name:$repo) {
44-
pullRequests(labels: ["request-ci"], states: OPEN, last: 100) {
45-
nodes {
46-
number
47-
}
48-
}
49-
}
50-
}
51-
owner: ${{ env.OWNER }}
52-
repo: ${{ env.REPOSITORY }}
53-
env:
54-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55-
5631
- name: Setup node-core-utils
5732
run: |
5833
ncu-config set username ${{ secrets.JENKINS_USER }}
5934
ncu-config set token none
6035
ncu-config set jenkins_token ${{ secrets.JENKINS_TOKEN }}
61-
ncu-config set owner ${{ env.OWNER }}
62-
ncu-config set repo ${{ env.REPOSITORY }}
36+
ncu-config set owner "${{ github.repository_owner }}"
37+
ncu-config set repo "$(echo ${{ github.repository }} | cut -d/ -f2)"
6338
64-
- name: Start CI
65-
run: ./tools/actions/start-ci.sh $(echo '${{ steps.get_prs_for_ci.outputs.data }}' | jq '.repository.pullRequests.nodes | map(.number) | .[]')
39+
- 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"
6643
env:
6744
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

‎.github/workflows/comment-labeled.yml

+3-6
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,9 @@ jobs:
1212
steps:
1313
- name: Post stalled comment
1414
env:
15-
COMMENTS_URL: ${{ github.event.issue.comments_url || github.event.pull_request.comments_url }}
16-
run: |
17-
curl -X POST $COMMENTS_URL \
18-
-H "Content-Type: application/json" \
19-
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
20-
--data '{ "body": "This issue/PR was marked as stalled, it will be automatically closed in 30 days. If it should remain open, please leave a comment explaining why it should remain open." }'
15+
NUMBER: ${{ github.event.issue.number || github.event.pull_request.number }}
16+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
17+
run: gh pr comment "$NUMBER" --repo ${{ github.repository }} --body "This issue/PR was marked as stalled, it will be automatically closed in 30 days. If it should remain open, please leave a comment explaining why it should remain open."
2118

2219
fastTrack:
2320
if: github.repository == 'nodejs/node' && github.event_name == 'pull_request_target' && github.event.label.name == 'fast-track'

‎.github/workflows/commit-queue.yml

+8-23
Original file line numberDiff line numberDiff line change
@@ -46,27 +46,6 @@ jobs:
4646
echo "OWNER=${{ github.repository_owner }}" >> $GITHUB_ENV
4747
echo "DEFAULT_BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
4848
49-
- name: Get Pull Requests
50-
uses: octokit/graphql-action@v2.x
51-
id: get_mergable_pull_requests
52-
with:
53-
query: |
54-
query release($owner:String!,$repo:String!, $base_ref:String!) {
55-
repository(owner:$owner, name:$repo) {
56-
pullRequests(baseRefName: $base_ref, labels: ["commit-queue"], states: OPEN, last: 100) {
57-
nodes {
58-
number
59-
}
60-
}
61-
}
62-
}
63-
owner: ${{ env.OWNER }}
64-
repo: ${{ env.REPOSITORY }}
65-
# Commit queue is only enabled for the default branch on the repository
66-
base_ref: ${{ env.DEFAULT_BRANCH }}
67-
env:
68-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
69-
7049
- name: Configure node-core-utils
7150
run: |
7251
ncu-config set branch ${DEFAULT_BRANCH}
@@ -77,7 +56,13 @@ jobs:
7756
ncu-config set repo "${REPOSITORY}"
7857
ncu-config set owner "${OWNER}"
7958
80-
- name: Start the commit queue
81-
run: ./tools/actions/commit-queue.sh ${OWNER} ${REPOSITORY} $(echo '${{ steps.get_mergable_pull_requests.outputs.data }}' | jq '.repository.pullRequests.nodes | map(.number) | .[]')
59+
- 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"
8267
env:
8368
GITHUB_TOKEN: ${{ secrets.GH_USER_TOKEN }}

0 commit comments

Comments
 (0)