File tree Expand file tree Collapse file tree 3 files changed +35
-1
lines changed
Expand file tree Collapse file tree 3 files changed +35
-1
lines changed Original file line number Diff line number Diff line change 88** /.env
99** /.editorconfig
1010** /dist
11+ /lib
1112** /* .pem
1213Dockerfile
Original file line number Diff line number Diff line change @@ -4,4 +4,4 @@ npm-debug.log
44! mock-cert.pem
55.env
66coverage
7- lib
7+ / lib
Original file line number Diff line number Diff line change 1+ import { Probot } from "probot" ;
2+ import { RestEndpointMethodTypes } from "@octokit/plugin-rest-endpoint-methods" ;
3+
4+ export type ProbotContext = Parameters < Parameters < Probot [ "on" ] > [ 1 ] > [ 0 ] ;
5+
6+ export type ChecksCreateParams =
7+ RestEndpointMethodTypes [ "checks" ] [ "create" ] [ "parameters" ] ;
8+
9+ export async function createOrUpdateCheck (
10+ context : ProbotContext ,
11+ params : ChecksCreateParams ,
12+ ) : Promise < void > {
13+ const existingChecks = await context . octokit . checks . listForRef ( {
14+ owner : params . owner ,
15+ repo : params . repo ,
16+ ref : params . head_sha ,
17+ check_name : params . name ,
18+ } ) ;
19+
20+ if ( existingChecks . data . check_runs . length > 0 ) {
21+ const existingCheck = existingChecks . data . check_runs [ 0 ] ;
22+ await context . octokit . checks . update ( {
23+ owner : params . owner ,
24+ repo : params . repo ,
25+ check_run_id : existingCheck . id ,
26+ status : params . status ,
27+ conclusion : params . conclusion ,
28+ output : params . output ,
29+ } ) ;
30+ } else {
31+ await context . octokit . checks . create ( params ) ;
32+ }
33+ }
You can’t perform that action at this time.
0 commit comments