Created
December 10, 2012 17:03
-
-
Save premist/4251851 to your computer and use it in GitHub Desktop.
Dead simple auto-deploy script for REMU
This file contains 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
require 'sinatra' | |
require 'json' | |
post '/' do | |
puts "Something is coming..." | |
if(!params[:payload]) | |
return "Not Github request - ignoring" | |
puts "Someone is bothering me." | |
end | |
push = JSON.parse(params[:payload]) | |
if (push['ref'] != 'refs/heads/master') | |
return "Not master push - ignoring" | |
end | |
repo = push['repository']['name']; | |
if (repo == 'remu-webclient') | |
Dir.chdir('/opt/remu-webapp') | |
elsif (repo == 'remu-server') | |
Dir.chdir('/opt/remu-server') | |
end | |
if(system("/usr/bin/git pull origin master")) | |
puts "Successfully pulled repository: #{repo}" | |
end | |
if (repo == 'remu-server') | |
if(system("forever stop /opt/remu-server/app.js && forever start /opt/remu-server/app.js")) | |
puts "Successfully restarted API server" | |
end | |
elsif (repo == 'remu-webclient') | |
if(system "grunt rebuild") | |
puts "Grunt job completed" | |
end | |
end | |
return "Job done!" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment