-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgithubClient.ts
More file actions
64 lines (56 loc) · 1.55 KB
/
githubClient.ts
File metadata and controls
64 lines (56 loc) · 1.55 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import { getOctokit } from '@actions/github'
import { context } from '@actions/github'
import { GhActionsContext } from './types.js'
export default class GitHubClient {
github
ctx
constructor(token: string, ctx: GhActionsContext) {
this.github = getOctokit(token)
this.ctx = ctx
}
async getCurrentWorkflowRun() {
return this.github.rest.actions.getWorkflowRun({
owner: this.ctx.repo.owner,
repo: this.ctx.repo.repo,
run_id: this.ctx.runId
})
}
async listWorkflowRuns(workflowId: number) {
return this.github.rest.actions.listWorkflowRuns({
owner: this.ctx.repo.owner,
repo: this.ctx.repo.repo,
workflow_id: workflowId
})
}
async listComments() {
return this.github.rest.issues.listComments({
owner: this.ctx.repo.owner,
repo: this.ctx.repo.repo,
issue_number: this.ctx.issue.number
})
}
async updateComment(commentId: number, body: string) {
return this.github.rest.issues.updateComment({
owner: this.ctx.repo.owner,
repo: this.ctx.repo.repo,
issue_number: this.ctx.issue.number,
comment_id: commentId,
body
})
}
async createComment(body: string) {
return this.github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: this.ctx.issue.number,
body
})
}
async deleteComment(commentId: number) {
return this.github.rest.issues.deleteComment({
owner: this.ctx.repo.owner,
repo: this.ctx.repo.repo,
comment_id: commentId
})
}
}