Last active
August 29, 2019 13:01
-
-
Save hyochan/5857e4d9557b901341e4f676e58a9194 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const secret = "dooboolab0!"; | |
const repo = "./whichwitch-server"; | |
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(sig != req.headers['x-hub-signature']){ | |
console.log('invalid key'); | |
var data = JSON.stringify({"error": "invalid key", key: sig}); | |
return res.end(data); | |
} | |
console.log('running'); | |
exec('cd ' + repo + ' && git pull'); | |
}); | |
res.end(); | |
}).listen(8081); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment