mirror of
https://github.com/dorny/test-reporter.git
synced 2026-03-21 23:52:12 +01:00
Document the new behavior for evaluating the associated commit
This commit is contained in:
parent
386854a5d3
commit
67e9e545d6
1 changed files with 3 additions and 0 deletions
|
|
@ -16,6 +16,9 @@ export function getCheckRunContext(): {sha: string; runId: number} {
|
||||||
throw new Error("Event of type 'workflow_run' is missing 'workflow_run' field")
|
throw new Error("Event of type 'workflow_run' is missing 'workflow_run' field")
|
||||||
}
|
}
|
||||||
const prs = (event.workflow_run.pull_requests ?? []) as WorkflowRunPR[]
|
const prs = (event.workflow_run.pull_requests ?? []) as WorkflowRunPR[]
|
||||||
|
// For `workflow_run`, we want to report against the PR commit when possible so annotations land
|
||||||
|
// on the contributor's changes. Prefer the PR whose `head.ref` matches `workflow_run.head_branch`,
|
||||||
|
// then fall back to the first PR head SHA, and finally to `workflow_run.head_sha` for non-PR runs.
|
||||||
const prShaMatch = prs.find(pr => pr.head?.ref === event.workflow_run.head_branch)?.head?.sha
|
const prShaMatch = prs.find(pr => pr.head?.ref === event.workflow_run.head_branch)?.head?.sha
|
||||||
const prShaFirst = prs[0]?.head?.sha
|
const prShaFirst = prs[0]?.head?.sha
|
||||||
const sha = prShaMatch ?? prShaFirst ?? event.workflow_run.head_sha
|
const sha = prShaMatch ?? prShaFirst ?? event.workflow_run.head_sha
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue