diff --git a/dist/index.js b/dist/index.js index 5f46655..7314d31 100644 --- a/dist/index.js +++ b/dist/index.js @@ -13603,8 +13603,9 @@ var external_fs_ = __webpack_require__(747); class se_Helper { - constructor(currentBuild) { + constructor(currentBuild, github) { this.currentBuild = currentBuild; + this.github = github; } createMetaJson(root) { const execSync = external_child_process_.execSync; @@ -13683,6 +13684,28 @@ class se_Helper { } 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" @@ -13746,7 +13769,7 @@ async function main() { opts.request = requestOpts; const github = Object(lib_github.getOctokit)(token, opts, dist_node.retry); 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. const result = await callAsyncFunction({ require: wrapRequire, diff --git a/src/main.ts b/src/main.ts index 25a31ff..31573c5 100644 --- a/src/main.ts +++ b/src/main.ts @@ -46,7 +46,7 @@ async function main(): Promise { 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( diff --git a/src/se.ts b/src/se.ts index f9f3e16..9f5ba77 100644 --- a/src/se.ts +++ b/src/se.ts @@ -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 - public constructor(currentBuild: typeof context) { + public constructor( + currentBuild: typeof context, + github: InstanceType + ) { 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 + } }