Last active
August 29, 2015 14:09
-
-
Save meandavejustice/8a2039e766bfcc7a6f4a 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
#!/bin/bash | |
git pull origin master | |
npm install | |
node server.js & |
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
var path = require('path'); | |
var spawn = require('child_process').spawn; | |
var createHandler = require("github-webhook-handler"); | |
var handler = createHandler({ | |
path: '/deploy', | |
secret: '***************************' | |
}); | |
handler.on('error', function (err) { | |
console.log('Error:', err.message) | |
}); | |
handler.on('push', function (event) { | |
setTimeout(function() { | |
var shell = process.env.SHELL; | |
var args = ['-c', 'bash deploy.sh']; | |
var projectPath = '/home/dave/www/project-name'; | |
var opts = { cwd: projectPath }; | |
console.log('[GITHUB] Spawning...', opts); | |
var spawnProcess = spawn(shell, args, opts); | |
spawnProcess.on('close', function(exitCode) { | |
console.log('[GITHUB] Spawn finished', exitCode); | |
console.log('[GITHUB] Exiting...'); | |
console.log('-------------------------------------------------------'); | |
}); | |
}, 1000); | |
}) | |
module.exports = function(req, res) { | |
handler(req, res, function(err) { | |
if (err) console.error(err); | |
res.statusCode = 404; | |
res.end('no such location'); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment