-
-
Notifications
You must be signed in to change notification settings - Fork 32
/
commit.ts
36 lines (29 loc) · 812 Bytes
/
commit.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import * as github from "@actions/github";
import { GitHub } from "@actions/github/lib/utils";
type Octokit = InstanceType<typeof GitHub>;
export async function getCommitChecksRunsStatus(
octokit: Octokit,
commitRef: string
) {
const { data } = await octokit.rest.checks.listForRef({
...github.context.repo,
ref: commitRef,
});
if (data.total_count === 0) {
return "completed";
}
if (data.check_runs.every((check) => check.status === "completed")) {
return "completed";
}
return "in_progress";
}
export async function getCommitStatusesStatus(
octokit: Octokit,
commitRef: string
) {
const { data } = await octokit.rest.repos.getCombinedStatusForRef({
...github.context.repo,
ref: commitRef,
});
return data.state as "success" | "pending" | "failure";
}