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

27
dist/index.js vendored
View file

@ -13603,8 +13603,9 @@ var external_fs_ = __webpack_require__(747);
class se_Helper { class se_Helper {
constructor(currentBuild) { constructor(currentBuild, github) {
this.currentBuild = currentBuild; this.currentBuild = currentBuild;
this.github = github;
} }
createMetaJson(root) { createMetaJson(root) {
const execSync = external_child_process_.execSync; const execSync = external_child_process_.execSync;
@ -13683,6 +13684,28 @@ class se_Helper {
} }
return ret; return ret;
} }
async startCheck(name, status) {
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;
}
async completeCheck(name, check_run_id, conclusion) {
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;
}
} }
// EXTERNAL MODULE: external "path" // EXTERNAL MODULE: external "path"
@ -13746,7 +13769,7 @@ async function main() {
opts.request = requestOpts; opts.request = requestOpts;
const github = Object(lib_github.getOctokit)(token, opts, dist_node.retry); const github = Object(lib_github.getOctokit)(token, opts, dist_node.retry);
const script = Object(core.getInput)('script', { required: true }); const script = Object(core.getInput)('script', { required: true });
const se = new se_Helper(lib_github.context); const se = new se_Helper(lib_github.context, github);
// Using property/value shorthand on `require` (e.g. `{require}`) causes compilation errors. // Using property/value shorthand on `require` (e.g. `{require}`) causes compilation errors.
const result = await callAsyncFunction({ const result = await callAsyncFunction({
require: wrapRequire, require: wrapRequire,

View file

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

View file

@ -1,12 +1,18 @@
import {context} from '@actions/github' import {context} from '@actions/github'
import {GitHub} from '@actions/github/lib/utils'
import * as child from 'child_process' import * as child from 'child_process'
import * as fs from 'fs' import * as fs from 'fs'
export class Helper { 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.currentBuild = currentBuild
this.github = github
} }
public createMetaJson(root: string) { public createMetaJson(root: string) {
@ -98,4 +104,32 @@ export class Helper {
} }
return ret 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
}
} }