export async function publishGitHubCheck()

in scan/src/utils.ts [573:599]


export async function publishGitHubCheck(
  failedByThreshold: boolean,
  name: string,
  output: Output
): Promise<void> {
  const conclusion = getGitHubCheckConclusion(
    output.annotations,
    failedByThreshold
  )
  const c = github.context
  const pr = c.payload.pull_request as PullRequestPayload | undefined
  let sha = c.sha
  if (pr) {
    sha = pr.head.sha
  }
  const client = github.getOctokit(getInputs().githubToken)
  const result = await client.rest.checks.listForRef({
    ...github.context.repo,
    ref: sha
  })
  const checkExists = result.data.check_runs.find(check => check.name === name)
  if (checkExists) {
    await updateCheck(client, conclusion, checkExists.id, output)
  } else {
    await createCheck(client, conclusion, sha, name, output)
  }
}