forked from kcwikizh/kcdata-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
29 lines (26 loc) · 957 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
const { exec } = require('child_process')
module.exports = app => {
app.log('kcdata-bot started!')
app.on('issues.labeled', async context => {
const { number } = context.payload.issue
const triggered = context.payload.issue.labels.some(label => label.name === 'bot/update')
if (!triggered) return
exec(`sh ./script/run.sh ${number}`, (err) => {
if (err) {
console.error(err)
return
}
const pr = context.github.pulls.create({
owner: 'kcwikizh',
repo: 'kcdata',
head: `bot-update-${number}`,
base: 'gh-pages',
maintainer_can_modify: true,
title: 'Update data by kcdata-bot',
body: `Triggered by #${number}\nMerge 前请务必检查内容是否填写完整。(例如:wiki_id是否填写完全)`
})
const issueComment = context.issue({ body: 'Done.' })
return context.github.issues.createComment(issueComment)
})
})
}