22 lines
No EOL
675 B
JavaScript
22 lines
No EOL
675 B
JavaScript
const secret = `${process.env.GITHUB_WEBHOOK}`
|
|
const repo = "/home/moover/MOOver"
|
|
|
|
const http = require('http')
|
|
const crypto = require('crypto')
|
|
const exec = require('child_process').exec
|
|
|
|
http.createServer(function (req, res) {
|
|
req.on('data', function (chunk) {
|
|
let sig = "sha1=" + crypto.createHmac('sha1', secret).update(chunk.toString()).digest('hex')
|
|
|
|
if (req.headers['x-hub-signature'] == sig) {
|
|
exec('cd ' + repo + ' && git pull' + '&& npm install' + 'pm2 restart 0')
|
|
}
|
|
})
|
|
|
|
res.end()
|
|
}).listen(5050, "127.0.0.1", () => {
|
|
console.log(`Server is running on http://"127.0.0.1":5050`)
|
|
})
|
|
|
|
console.log("running webhook!") |