FYI: this has nothing to do with SSH keys - therefore private repos wont work with this.
const secret = 'your_secret_here';
const repopwd = '/your_repo_path_here/';
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 ${repopwd} && git pull`);
}
});
res.end();
}).listen(8080);