Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/workflows/ci-summary-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,17 @@ jobs:
RUN_ID="${{ github.event.workflow_run.id }}"
PR_NUMBER="${{ github.event.workflow_run.pull_requests[0].number }}"
HEAD_SHA="${{ github.event.workflow_run.pull_requests[0].head.sha || github.event.workflow_run.head_sha }}"

# workflow_run.pull_requests is empty for fork PRs (renovate-bot, dependabot, etc.).
# Fall back to searching for a PR matching the head branch.
Comment on lines +72 to +73
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment says fork PRs are "(renovate-bot, dependabot, etc.)", but those actors don't necessarily imply a cross-repo fork (e.g., dependabot PRs are typically branches on the same repo). Consider rewording to describe the actual condition (workflow_run.pull_requests is empty for cross-repo fork PRs) to avoid misleading future readers.

Suggested change
# workflow_run.pull_requests is empty for fork PRs (renovate-bot, dependabot, etc.).
# Fall back to searching for a PR matching the head branch.
# For cross-repo fork PRs, workflow_run.pull_requests is empty in the event payload.
# In that case, fall back to searching for a PR matching the head branch and commit.

Copilot uses AI. Check for mistakes.
if [ -z "$PR_NUMBER" ] && [ "${{ github.event.workflow_run.event }}" == "pull_request" ]; then
PR_NUMBER=$(gh pr list \
--repo "${{ github.repository }}" \
--search "head:${{ github.event.workflow_run.head_branch }}" \
--json number,headRefOid \
--jq ".[] | select(.headRefOid == \"$HEAD_SHA\") | .number")
echo "Resolved PR #$PR_NUMBER from head branch (fork PR fallback)"
Comment on lines +78 to +80
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gh pr list can return multiple PRs for the same head: search (e.g., same branch name across forks), and the current --jq expression would then output multiple numbers separated by newlines. That can corrupt subsequent $GITHUB_OUTPUT writes (pr_number=$PR_NUMBER) and make the workflow flaky. Consider constraining the query (--limit 1, --state open) and/or making the jq expression return a single scalar (e.g., pick the first match) and only logging success when PR_NUMBER is non-empty/non-null.

Suggested change
--json number,headRefOid \
--jq ".[] | select(.headRefOid == \"$HEAD_SHA\") | .number")
echo "Resolved PR #$PR_NUMBER from head branch (fork PR fallback)"
--state open \
--limit 20 \
--json number,headRefOid \
--jq "map(select(.headRefOid == \"$HEAD_SHA\")) | .[0].number")
if [ -n "$PR_NUMBER" ] && [ "$PR_NUMBER" != "null" ]; then
echo "Resolved PR #$PR_NUMBER from head branch (fork PR fallback)"
fi

Copilot uses AI. Check for mistakes.
Comment on lines +73 to +80
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fork-PR fallback is likely never going to match because HEAD_SHA falls back to github.event.workflow_run.head_sha, which (for workflows triggered by pull_request) is typically the PR merge commit SHA, while gh pr list --json headRefOid returns the PR head commit OID. This means the select(.headRefOid == "$HEAD_SHA") filter will often produce no results and PR_NUMBER stays empty. Prefer resolving the PR number directly from the run SHA via the REST endpoint repos/{owner}/{repo}/commits/{sha}/pulls (or request/compare against the PR's merge commit OID instead of headRefOid).

Suggested change
# Fall back to searching for a PR matching the head branch.
if [ -z "$PR_NUMBER" ] && [ "${{ github.event.workflow_run.event }}" == "pull_request" ]; then
PR_NUMBER=$(gh pr list \
--repo "${{ github.repository }}" \
--search "head:${{ github.event.workflow_run.head_branch }}" \
--json number,headRefOid \
--jq ".[] | select(.headRefOid == \"$HEAD_SHA\") | .number")
echo "Resolved PR #$PR_NUMBER from head branch (fork PR fallback)"
# Fall back to resolving the PR directly from the run's commit SHA.
if [ -z "$PR_NUMBER" ] && [ "${{ github.event.workflow_run.event }}" == "pull_request" ]; then
PR_NUMBER=$(gh api "repos/${{ github.repository }}/commits/$HEAD_SHA/pulls" --jq '.[0].number')
echo "Resolved PR #$PR_NUMBER from commit SHA $HEAD_SHA (fork PR fallback)"

Copilot uses AI. Check for mistakes.
fi
fi

echo "run_id=$RUN_ID" >> $GITHUB_OUTPUT
Expand Down
Loading