Created
July 5, 2013 15:12
-
-
Save 5minpause/5935203 to your computer and use it in GitHub Desktop.
small sinatra app to listen for a post-receive hook and deploy my blog 5minutenpause.com
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 | |
if params && params[:payload] | |
push = JSON.parse(params[:payload]) | |
commits = push['commits'] | |
num_of_commits = push['commits'].length | |
last_commit_message = commits[num_of_commits-1]['message'] | |
if last_commit_message =~ /publish/ | |
output = `cd local_octopress_directory && git pull ; cd local_octopress_directory && bundle install ; cd local_octopress_directory && bundle exec rake -f local_octopress_directory/Rakefile gen_deploy RAILS_ENV=development 2>&1` | |
"deployed to site: #{output}" | |
else | |
'nothing to publish. doing nothing' | |
end | |
end | |
end | |
get '/' do | |
'nothing to see here.' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment