-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
33 lines (24 loc) · 862 Bytes
/
index.js
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
module.exports = (app) => {
// Your code here
app.log('Yay! The app was loaded!')
// example of probot responding 'Hello World' to a new issue being opened
app.on(['pull_request.opened', 'pull_request.reopened', 'pull_request.edited'], async context => {
const config = await context.config("label.yml")
if (!config) {
console.log("Config missing!")
return
}
var labelsToAdd = []
var body = context.payload.pull_request.body
if (body.includes(":cl:")) {
var capture = body.match(/:cl:(.|\n|\r)*?\/:cl:/gm)
console.log(capture)
}
for (let token in config.tags) {
if (capture.toString().includes(token)) {
labelsToAdd.push(config.tags[token])
}
}
return context.octokit.issues.addLabels(context.issue({ labels: labelsToAdd }))
})
}