Webhook fix
This commit is contained in:
parent
ba3c061d8d
commit
89fecf85be
1 changed files with 5 additions and 10 deletions
|
@ -1,15 +1,14 @@
|
|||
const secret = `${process.env.GITHUB_WEBHOOK}`
|
||||
const repo = "/home/moover/MOOver"
|
||||
|
||||
require('dotenv').config()
|
||||
const http = require('http')
|
||||
const crypto = require('crypto')
|
||||
const exec = require('child_process').exec
|
||||
|
||||
const secret = `${process.env.GITHUB_WEBHOOK}`
|
||||
const repo = "/home/moover/MOOver"
|
||||
|
||||
http.createServer(function (req, res) {
|
||||
req.on('data', function (chunk) {
|
||||
let sig = "sha1=" + crypto.createHmac('sha1', secret).update(chunk.toString()).digest('hex')
|
||||
|
||||
console.log(`Got a request! comparing ${process.env.GITHUB_WEBHOOK} \n==\n ${req.headers["x-hub-signature"]}`)
|
||||
if (req.headers["x-hub-signature"] == sig) {
|
||||
console.log("updating moover...")
|
||||
exec("pm2 stop 'MOOver - main' && " + " cd " + repo + "&& git pull" + " && npm install" + " pm2 start 'MOOver - main'")
|
||||
|
@ -21,10 +20,6 @@ http.createServer(function (req, res) {
|
|||
res.end('Hello World\n')
|
||||
|
||||
}).listen(5050, "127.0.0.1", () => {
|
||||
console.log(`Server is running on http://"127.0.0.1":5050`)
|
||||
console.log(`Server is running`)
|
||||
})
|
||||
|
||||
|
||||
|
||||
console.log("running webhook!")
|
||||
|
||||
|
|
Loading…
Reference in a new issue