-
Notifications
You must be signed in to change notification settings - Fork 120
Expand file tree
/
Copy pathtriageIssue.js
More file actions
151 lines (123 loc) · 4.72 KB
/
Copy pathtriageIssue.js
File metadata and controls
151 lines (123 loc) · 4.72 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
module.exports = async({github, context}) => {
const owner = context.repo.owner;
const repo = context.repo.repo;
const issue = context.payload.issue;
const issueNumber = issue.number;
const issueDescription = issue.body;
const username = issue.user.login
if(context.eventName === 'issues'){
try {
if(!issueDescription || !issueDescription.trim()){
return await github.rest.issues.createComment({
owner,
repo,
issue_number: issueNumber,
body: `Hi @${username},
Thanks for opening this issue.
It looks like the issue description is currently missing.
Please provide:
- A brief summary of the problem
- Expected behavior
- Actual behavior (if applicable)
- Any relevant screenshots, logs, or context
This helps the team understand, prioritize, and route the issue correctly.
Thank you!
`
})
}
return await github.rest.issues.createComment({
owner,
repo,
issue_number: issueNumber,
body: `Hi @${username},
Thanks for opening this issue.
Please reply with one of the following areas so the issue can be routed to the appropriate team member:
- /backend
- /web
- /mobile
- /devops
Once an area is selected, the corresponding label will be added automatically.`
})
} catch (error) {
console.error(error)
}
}else if(context.eventName === 'issue_comment'){
if (context.payload.comment.user.type === 'Bot' || context.payload.comment.user.login === 'github-actions[bot]') {
return;
}
const comment = (context.payload.comment.body || '').trim().toLowerCase();
const existingLabels = (issue.labels || []).map(label => label.name);
if (
existingLabels.includes('backend') ||
existingLabels.includes('web') ||
existingLabels.includes('mobile') ||
existingLabels.includes('devops')
) {
return;
}
if (!['/backend', '/web', '/mobile', '/devops'].includes(comment)) {
return;
}
if(comment === '/backend'){
await github.rest.issues.addLabels({
owner,
repo,
issue_number: issueNumber,
labels: ['backend']
})
return await github.rest.issues.createComment({
owner,
repo,
issue_number: issueNumber,
body: `The issue has been classified as **backend**.
@Harxhit, please review and triage this issue when available.
The **backend** label has been applied and the issue has been routed accordingly.`
})
}else if(comment === '/web'){
await github.rest.issues.addLabels({
owner,
repo,
issue_number: issueNumber,
labels: ['web']
})
return await github.rest.issues.createComment({
owner,
repo,
issue_number: issueNumber,
body: `The issue has been classified as **web**.
@ShantKhatri, please review and triage this issue when available.
The **web** label has been applied and the issue has been routed accordingly.`
})
}else if(comment === '/mobile'){
await github.rest.issues.addLabels({
owner,
repo,
issue_number: issueNumber,
labels: ['mobile']
})
return await github.rest.issues.createComment({
owner,
repo,
issue_number: issueNumber,
body: `The issue has been classified as **mobile**.
@blankirigaya, please review and triage this issue when available.
The **mobile** label has been applied and the issue has been routed accordingly.`
})
}else if(comment === '/devops'){
await github.rest.issues.addLabels({
owner,
repo,
issue_number: issueNumber,
labels: ['devops']
})
return await github.rest.issues.createComment({
owner,
repo,
issue_number: issueNumber,
body: `The issue has been classified as **devops**.
@ShantKhatri, please review and triage this issue when available.
The **devops** label has been applied and the issue has been routed accordingly.`
})
}
}
}