Skip to content

Instantly share code, notes, and snippets.

@hyochan
Last active August 29, 2019 13:01
Show Gist options
  • Save hyochan/5857e4d9557b901341e4f676e58a9194 to your computer and use it in GitHub Desktop.
Save hyochan/5857e4d9557b901341e4f676e58a9194 to your computer and use it in GitHub Desktop.
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