-
Notifications
You must be signed in to change notification settings - Fork 15
/
index.js
28 lines (24 loc) · 868 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
const template = require('./template')
const attachTo = {
issue: (context, content) => {
const { issue, pull_request: pr } = context.payload
const body = (issue || pr).body + '\n\n' + content.join('\n')
const params = context.issue({body})
return context.github.issues.edit(params)
},
comment: (context, content) => {
const body = context.payload.comment.body + '\n\n' + content.join('\n')
const id = context.payload.comment.id
const params = context.repo({id, body})
return context.github.issues.editComment(params)
}
}
module.exports = function attachments (context) {
const attach = context.payload.comment ? attachTo.comment : attachTo.issue
return {
async add (attachments) {
const content = [].concat(attachments).map(attachment => template(attachment))
return attach(context, content)
}
}
}