fix(ci): use REST API to find PRs by branch in workflows
`gh pr view` queries with a hidden `first: 30` which fails to find PRs when the target PR falls outside the first page. The REST API filters by `head=owner:branch` server-side which avoid this limitation.
This commit is contained in:
@@ -32,8 +32,9 @@ jobs:
|
||||
}}
|
||||
# Query the PR number by repo + branch, then assign to step output:
|
||||
run: |
|
||||
gh pr view --repo "${PR_TARGET_REPO}" "${PR_BRANCH}" \
|
||||
--json 'number' --jq '"number=\(.number)"' \
|
||||
gh api "repos/${PR_TARGET_REPO}/pulls" \
|
||||
--method GET -f head="${PR_BRANCH}" -f state=open \
|
||||
--jq '.[0] | "number=\(.number)"' \
|
||||
>> "${GITHUB_OUTPUT}"
|
||||
|
||||
- name: Fetch PR data via GitHub API
|
||||
@@ -180,8 +181,9 @@ jobs:
|
||||
}}
|
||||
# Query the PR number by repo + branch, then assign to step output:
|
||||
run: |
|
||||
gh pr view --repo "${PR_TARGET_REPO}" "${PR_BRANCH}" \
|
||||
--json 'number' --jq '"number=\(.number)"' \
|
||||
gh api "repos/${PR_TARGET_REPO}/pulls" \
|
||||
--method GET -f head="${PR_BRANCH}" -f state=open \
|
||||
--jq '.[0] | "number=\(.number)"' \
|
||||
>> "${GITHUB_OUTPUT}"
|
||||
|
||||
- name: Pull Request Labeler
|
||||
|
||||
@@ -38,8 +38,9 @@ jobs:
|
||||
|| github.event.workflow_run.head_branch
|
||||
}}
|
||||
run: |
|
||||
gh pr view --repo "${PR_TARGET_REPO}" "${PR_BRANCH}" \
|
||||
--json 'number' --jq '"number=\(.number)"' \
|
||||
gh api "repos/${PR_TARGET_REPO}/pulls" \
|
||||
--method GET -f head="${PR_BRANCH}" -f state=open \
|
||||
--jq '.[0] | "number=\(.number)"' \
|
||||
>> "${GITHUB_OUTPUT}"
|
||||
|
||||
- name: Check PR author
|
||||
|
||||
Reference in New Issue
Block a user