-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauto_build.js
46 lines (39 loc) · 1.59 KB
/
auto_build.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
34
35
36
37
38
39
40
41
42
43
44
45
46
// // 因为密钥的问题 这个功能已经独立出来了
// var http = require('http')
// var spawn = require('child_process').spawn
// var createHandler = require('github-webhook-handler')
// // 下面填写的myscrect跟github webhooks配置一样,下一步会说;path是我们访问的路径
// var handler = createHandler({ path: '/auto_build', secret: '' })
// http.createServer(function (req, res) {
// handler(req, res, function () {
// res.statusCode = 404
// res.end('no such location')
// })
// console.log('listen on 6666')
// }).listen(6666)
// handler.on('error', function (err) {
// console.error('Error:', err.message)
// })
// // 监听到push事件的时候执行我们的自动化脚本
// handler.on('push', function (event) {
// console.log('Received a push event for %s to %s',
// event.payload.repository.name,
// event.payload.ref)
// runCommand('sh', ['./auto_build.sh'], function (txt) {
// console.log(txt)
// })
// })
// function runCommand (cmd, args, callback) {
// var child = spawn(cmd, args)
// var resp = ''
// child.stdout.on('data', function (buffer) { resp += buffer.toString() })
// child.stdout.on('end', function () { callback(resp) })
// }
// // 由于我们不需要监听issues,所以下面代码注释掉
// // handler.on('issues', function (event) {
// // console.log('Received an issue event for %s action=%s: #%d %s',
// // event.payload.repository.name,
// // event.payload.action,
// // event.payload.issue.number,
// // event.payload.issue.title)
// // });