diff --git a/.github/workflows/pr-test.yml b/.github/workflows/pr-test.yml index 69d572d20..fbccef871 100644 --- a/.github/workflows/pr-test.yml +++ b/.github/workflows/pr-test.yml @@ -209,10 +209,20 @@ jobs: elif [[ "${{ github.event_name }}" == "pull_request" && "${{ contains(github.event.pull_request.labels.*.name, 'high priority') }}" == "true" ]]; then echo "max_parallel=14" >> $GITHUB_OUTPUT echo "High priority PR detected, setting max_parallel to 14" - elif [[ -n "${{ inputs.pr_head_sha }}" ]]; then + elif [[ -n "${{ inputs.target_stage }}" ]]; then # /rerun-stage (workflow_dispatch): query PR labels via GitHub API - LABELS=$(gh api "repos/${{ github.repository }}/commits/${{ inputs.pr_head_sha }}/pulls" \ - --jq '.[0].labels[].name' 2>/dev/null || true) + # Try SHA lookup first (fork PRs), fallback to branch name (non-fork PRs) + LABELS="" + PR_HEAD_SHA="${{ inputs.pr_head_sha }}" + if [[ -n "$PR_HEAD_SHA" ]]; then + LABELS=$(gh api "repos/${{ github.repository }}/commits/${PR_HEAD_SHA}/pulls" \ + --jq '.[0].labels[].name' 2>/dev/null || true) + fi + if [[ -z "$LABELS" ]]; then + LABELS=$(gh pr list --head "${{ github.ref_name }}" --repo "${{ github.repository }}" \ + --json labels --jq '.[0].labels[].name' 2>/dev/null || true) + fi + echo "PR labels: ${LABELS:-"(none)"}" if echo "$LABELS" | grep -Fxq "high priority"; then echo "max_parallel=14" >> $GITHUB_OUTPUT echo "High priority PR detected via API (/rerun-stage), setting max_parallel to 14"