forked from riyadhalnur/issuelabeler
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
17 lines (14 loc) · 746 Bytes
/
index.js
File metadata and controls
17 lines (14 loc) · 746 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
module.exports = (robot) => {
robot.on('issues.opened', async context => {
const config = await context.config('labeler.yml', { numLabels: 20 })
const labels = await context.github.issues.getLabels(context.issue({ per_page: config.numLabels }))
const issue = await context.github.issues.get(context.issue())
let labelList = []
let labelsToAdd = []
labels.data.map(label => labelList.push(label.name))
labelList
.filter(label => !config.excludeLabels.includes(label))
.map(label => issue.data.title.toLowerCase().includes(label) || issue.data.body.toLowerCase().includes(label) ? labelsToAdd.push(label) : null)
return context.github.issues.addLabels(context.issue({ labels: labelsToAdd }))
})
}