fix: use pulls API instead of gh pr view for PR/issue detection

gh pr view can't distinguish PRs from issues — it succeeds for both.
Use the REST API endpoint repos/{owner}/{repo}/pulls/{number} which
returns 404 for issues.
This commit is contained in:
snomiao
2026-03-23 18:08:49 +00:00
parent 836492e3dc
commit 2c08a98117

View File

@@ -96,7 +96,8 @@ jobs:
echo "number=${NUM}" >> "$GITHUB_OUTPUT"
if [ -n "$NUM" ]; then
if gh pr view "$NUM" --repo "$REPO" --json number >/dev/null 2>&1; then
# Use the API to check if it's a PR (gh pr view can't distinguish)
if gh api "repos/${REPO}/pulls/${NUM}" --jq '.number' >/dev/null 2>&1; then
echo "target_type=pr" >> "$GITHUB_OUTPUT"
echo "Target: PR #$NUM"
else
@@ -492,7 +493,7 @@ jobs:
echo "number=${NUM}" >> "$GITHUB_OUTPUT"
if [ -n "$NUM" ]; then
if gh pr view "$NUM" --repo "$REPO" --json number >/dev/null 2>&1; then
if gh api "repos/${REPO}/pulls/${NUM}" --jq '.number' >/dev/null 2>&1; then
echo "target_type=pr" >> "$GITHUB_OUTPUT"
else
echo "target_type=issue" >> "$GITHUB_OUTPUT"