Skip to content

Commit

Permalink
build: use gh cli in workflows file
Browse files Browse the repository at this point in the history
  • Loading branch information
Mesteery committed Nov 26, 2021
1 parent 49b8c4f commit b966c11
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 49 deletions.
26 changes: 4 additions & 22 deletions .github/workflows/auto-start-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,6 @@ jobs:
echo "REPOSITORY=$(echo ${{ github.repository }} | cut -d/ -f2)" >> $GITHUB_ENV
echo "OWNER=${{ github.repository_owner }}" >> $GITHUB_ENV
# Get Pull Requests
- name: Get Pull Requests
uses: octokit/graphql-action@v2.x
id: get_prs_for_ci
with:
query: |
query prs($owner:String!, $repo:String!) {
repository(owner:$owner, name:$repo) {
pullRequests(labels: ["request-ci"], states: OPEN, last: 100) {
nodes {
number
}
}
}
}
owner: ${{ env.OWNER }}
repo: ${{ env.REPOSITORY }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Setup node-core-utils
run: |
ncu-config set username ${{ secrets.JENKINS_USER }}
Expand All @@ -59,7 +39,9 @@ jobs:
ncu-config set owner ${{ env.OWNER }}
ncu-config set repo ${{ env.REPOSITORY }}
- name: Start CI
run: ./tools/actions/start-ci.sh $(echo '${{ steps.get_prs_for_ci.outputs.data }}' | jq '.repository.pullRequests.nodes | map(.number) | .[]')
- name: Get Pull Requests and start CI
run: |
prs=`gh pr list --repo ${{ github.repository }} --limit 100 --json number -q 'map(.number) | .[]'`
./tools/actions/start-ci.sh $(echo $prs)
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9 changes: 3 additions & 6 deletions .github/workflows/comment-labeled.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,9 @@ jobs:
steps:
- name: Post stalled comment
env:
COMMENTS_URL: ${{ github.event.issue.comments_url || github.event.pull_request.comments_url }}
run: |
curl -X POST $COMMENTS_URL \
-H "Content-Type: application/json" \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
--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." }'
NUMBER: ${{ github.event.number || github.event.issue.number }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
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."

fastTrack:
if: github.repository == 'nodejs/node' && github.event_name == 'pull_request_target' && github.event.label.name == 'fast-track'
Expand Down
28 changes: 7 additions & 21 deletions .github/workflows/commit-queue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,27 +46,6 @@ jobs:
echo "OWNER=${{ github.repository_owner }}" >> $GITHUB_ENV
echo "DEFAULT_BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
- name: Get Pull Requests
uses: octokit/graphql-action@v2.x
id: get_mergable_pull_requests
with:
query: |
query release($owner:String!,$repo:String!, $base_ref:String!) {
repository(owner:$owner, name:$repo) {
pullRequests(baseRefName: $base_ref, labels: ["commit-queue"], states: OPEN, last: 100) {
nodes {
number
}
}
}
}
owner: ${{ env.OWNER }}
repo: ${{ env.REPOSITORY }}
# Commit queue is only enabled for the default branch on the repository
base_ref: ${{ env.DEFAULT_BRANCH }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Configure node-core-utils
run: |
ncu-config set branch ${DEFAULT_BRANCH}
Expand All @@ -81,3 +60,10 @@ jobs:
run: ./tools/actions/commit-queue.sh ${OWNER} ${REPOSITORY} $(echo '${{ steps.get_mergable_pull_requests.outputs.data }}' | jq '.repository.pullRequests.nodes | map(.number) | .[]')
env:
GITHUB_TOKEN: ${{ secrets.GH_USER_TOKEN }}

- name: Get Pull Requests and start the commit queue
run: |
prs=`gh pr list --repo ${{ github.repository }} --base ${{ env.DEFAULT_BRANCH }} --limit 100 --json number -q 'map(.number) | .[]'`
./tools/actions/commit-queue.sh ${OWNER} ${REPOSITORY} $(echo $prs)
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit b966c11

Please sign in to comment.