1
0
Fork 0
mirror of https://github.com/dorny/test-reporter.git synced 2026-03-22 07:52:14 +01:00

Simplify the code as the cast to WorkflowRunPR type is not necessary

Fixes the error:

```
test-reporter/src/utils/github-utils.ts
  18:17  error  This assertion is unnecessary since it does not change the type of the expression  @typescript-eslint/no-unnecessary-type-assertion
```
This commit is contained in:
Jozef Izso 2026-03-02 13:17:13 +01:00
parent 67e9e545d6
commit 8446e5e701
Failed to extract signature

View file

@ -6,8 +6,6 @@ import * as github from '@actions/github'
import {GitHub} from '@actions/github/lib/utils'
import type {PullRequest, WorkflowRunEvent} from '@octokit/webhooks-types'
type WorkflowRunPR = WorkflowRunEvent['workflow_run']['pull_requests'][number]
export function getCheckRunContext(): {sha: string; runId: number} {
if (github.context.eventName === 'workflow_run') {
core.info('Action was triggered by workflow_run: using SHA and RUN_ID from triggering workflow')
@ -15,7 +13,7 @@ export function getCheckRunContext(): {sha: string; runId: number} {
if (!event.workflow_run) {
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 ?? []
// 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.