-
-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathcontext.ts
75 lines (63 loc) · 1.79 KB
/
context.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
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
65
66
67
68
69
70
71
72
73
74
75
export function getRepoOwnerLogin(ctx: any): string {
return ctx.payload.repository.owner.login
}
export function getRepoOwnerId(ctx: any) {
return ctx.payload.repository.owner.id
}
export function getRepoName(ctx: any): string {
return ctx.payload.repository.name
}
export function getIssueNumber(ctx: any) {
return ctx.payload.issue.number
}
export function getIssueDescription(ctx: any) {
return ctx.payload.issue.body
}
export function getIssueTitle(ctx: any) {
return ctx.payload.issue.title
}
export function getDefaultBranch(ctx: any) {
return ctx.payload.repository.default_branch
}
export function isOrgRepo(ctx: any) {
const {repository} = ctx.payload;
return repository.owner.type === 'Organization';
}
export function getIssueLabels(ctx: any) {
const labels = ctx.payload.issue.labels
return labels.map((l: { name: string }) => l.name)
}
export function getIssueLabelsForMatching(ctx: any) {
const labels = ctx.payload.issue.labels.map((l: { name: string }) => l.name)
if (labels.length === 0) {
return ['']
} else {
return labels
}
}
export function getAssignee(ctx: any) {
const {payload} = ctx
const {issue} = payload
if (issue.assignee) {
return issue.assignee.login
}
if (issue.assignees && issue.assignees.length > 0) {
return issue.assignees[0].login
}
if (payload.assignee) {
return payload.assignee.login
}
if (payload.assignees && issue.assignees.length > 0) {
return payload.assignees[0].login
}
}
export function getSender(ctx: any) {
return ctx.payload.sender.login
}
export function getMilestoneNumber(ctx: any) {
const {payload} = ctx
const {issue} = payload
if (issue.milestone) {
return issue.milestone.number
}
}