Skip to content

Commit 04b5741

Browse files
committed
fix(bot): fix .gitignore to not exclude src/lib/
1 parent 49e5d40 commit 04b5741

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

apps/bot/.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@
88
**/.env
99
**/.editorconfig
1010
**/dist
11+
/lib
1112
**/*.pem
1213
Dockerfile

apps/bot/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ npm-debug.log
44
!mock-cert.pem
55
.env
66
coverage
7-
lib
7+
/lib

apps/bot/src/lib/github-checks.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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+
}

0 commit comments

Comments
 (0)