-
Notifications
You must be signed in to change notification settings - Fork 0
/
webhook.js
34 lines (29 loc) · 1.01 KB
/
webhook.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
const http = require('http');
const crypto = require('crypto');
const exec = require('child_process').exec;
const secret = "wued@2019";
//const repo = "C://github/wued-dreamer";
//打开 8080 端口监听来自 Github 的 Push 推送
http.createServer(function (req, res) {
let chunks = ''
req.on('data', function(chunk) {
chunks += chunk.toString();
const sig = "sha1=" + crypto.createHmac('sha1', secret).update(chunks).digest('hex');
if (req.headers['x-hub-signature'] == sig) {
exec('git pull');
//exec('cd ' + repo + ' && git pull');
}
});
res.end('Hello World Form WUEDDreamerHook\n');
}).listen(8080);
// const http = require('http');
// const hostname = '0.0.0.0';
// const port = 8080;
// const server = http.createServer((req, res) => {
// res.statusCode = 200;
// res.setHeader('Content-Type', 'text/plain');
// res.end('Hello World\n');
// });
// server.listen(port, hostname, () => {
// console.log(`Server running at http://${hostname}:${port}/`);
// });