mirror of
https://github.com/dorny/test-reporter.git
synced 2025-12-17 06:47:09 +01:00
Process input and create check-run
This commit is contained in:
parent
bc706859ad
commit
e97dbdd3e5
8 changed files with 13780 additions and 44 deletions
13
src/utils/file-utils.ts
Normal file
13
src/utils/file-utils.ts
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
import * as fs from 'fs'
|
||||
|
||||
export function getFileContent(path: string): string {
|
||||
if (!fs.existsSync(path)) {
|
||||
throw new Error(`File '${path}' not found`)
|
||||
}
|
||||
|
||||
if (!fs.lstatSync(path).isFile()) {
|
||||
throw new Error(`'${path}' is not a file`)
|
||||
}
|
||||
|
||||
return fs.readFileSync(path, {encoding: 'utf8'})
|
||||
}
|
||||
11
src/utils/github-utils.ts
Normal file
11
src/utils/github-utils.ts
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
import * as github from '@actions/github'
|
||||
import {EventPayloads} from '@octokit/webhooks'
|
||||
|
||||
export function getCheckRunSha(): string {
|
||||
if (github.context.payload.pull_request) {
|
||||
const pr = github.context.payload.pull_request as EventPayloads.WebhookPayloadPullRequestPullRequest
|
||||
return pr.head.sha
|
||||
}
|
||||
|
||||
return github.context.sha
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue