Skip to content

Instantly share code, notes, and snippets.

@chip
Created November 28, 2012 00:09
Show Gist options
  • Save chip/4158086 to your computer and use it in GitHub Desktop.
Save chip/4158086 to your computer and use it in GitHub Desktop.
Sinatra app to deploy master branch based on SemaphoreApp payload
# Inspired by http://www.travisberry.com/2012/02/hubot-deploy/
require 'rubygems'
require 'sinatra'
require 'yajl'
get '/' do
"Whatchu talkin bout, Willis?"
end
post '/deploy' do
puts "Reading request body..."
json = request.body.read
puts "Parsing JSON data..."
data = Yajl::Parser.parse(json)
puts data
if data['branch_name'] == 'master' && data['result'] == 'passed'
command = "cd ~/public_html/rentwb_for_deployment; git pull origin master;" # cap deploy staging"
puts command
pipe = IO.popen(command)
response = pipe.readlines
puts response.join
else
puts "Nothing to do here. Buh-bye"
end
end
source :rubygems
gem 'shotgun'
gem 'sinatra'
gem 'yajl-ruby'
@chip
Copy link
Author

chip commented Nov 28, 2012

Still need to add Campfire integration

@chip
Copy link
Author

chip commented Nov 28, 2012

NameVirtualHost *:8181

<VirtualHost *:8181>
  ServerName 50.56.23.249
  DocumentRoot /var/www/deploy/public
  <Directory /var/www/deploy/public>
    AllowOverride all
    Options -MultiViews
  </Directory>
</VirtualHost>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment