Added start and end

This commit is contained in:
Jonas Bovin 2022-11-22 17:07:46 +01:00
parent e4f7f1688c
commit 1bc237c625
3 changed files with 62 additions and 5 deletions

View file

@ -46,7 +46,7 @@ async function main(): Promise<void> {
const github = getOctokit(token, opts, retry)
const script = core.getInput('script', {required: true})
const se = new helper.Helper(context)
const se = new helper.Helper(context, github)
// Using property/value shorthand on `require` (e.g. `{require}`) causes compilation errors.
const result = await callAsyncFunction(

View file

@ -1,12 +1,18 @@
import {context} from '@actions/github'
import {GitHub} from '@actions/github/lib/utils'
import * as child from 'child_process'
import * as fs from 'fs'
export class Helper {
public currentBuild: typeof context
currentBuild: typeof context
github: InstanceType<typeof GitHub>
public constructor(currentBuild: typeof context) {
public constructor(
currentBuild: typeof context,
github: InstanceType<typeof GitHub>
) {
this.currentBuild = currentBuild
this.github = github
}
public createMetaJson(root: string) {
@ -98,4 +104,32 @@ export class Helper {
}
return ret
}
public async startCheck(name: string, status: string) {
const result = await this.github.rest.checks.create({
owner: this.currentBuild.repo.owner,
repo: this.currentBuild.repo.repo,
name: name,
head_sha: this.currentBuild.sha,
status: status
})
return result
}
public async completeCheck(
name: string,
check_run_id: string,
conclusion: string
) {
const result = await this.github.rest.checks.create({
owner: this.currentBuild.repo.owner,
repo: this.currentBuild.repo.repo,
name: name,
check_run_id: check_run_id,
head_sha: this.currentBuild.sha,
status: 'completed',
conclusion: conclusion
})
return result
}
}