Skip to content

Instantly share code, notes, and snippets.

@ninetwentyfour
Created February 16, 2012 21:07
Show Gist options
  • Save ninetwentyfour/1847866 to your computer and use it in GitHub Desktop.
Save ninetwentyfour/1847866 to your computer and use it in GitHub Desktop.
Hubot Deploy 1 - blogpost
# Deploy with capistrano
#
# Usage:
# deploy <repo>
# what can you deploy?
#
hackers = [
"http://hubot-assets.s3.amazonaws.com/hackers/1.gif",
"http://hubot-assets.s3.amazonaws.com/hackers/2.gif",
"http://hubot-assets.s3.amazonaws.com/hackers/3.gif",
"http://hubot-assets.s3.amazonaws.com/hackers/4.gif",
"http://hubot-assets.s3.amazonaws.com/hackers/5.gif",
"http://hubot-assets.s3.amazonaws.com/hackers/6.gif",
"http://hubot-assets.s3.amazonaws.com/hackers/7.gif",
]
#array of the repo names to match and deploy
repos = [
"example_app_1",
"example_app_2",
"example_app_3"
]
module.exports = (robot) ->
robot.respond /deploy (.+)/i, (msg) ->
if msg.match[1] in repos
#send waiting messages
msg.send 'Attempting deploy. Please hold.'
msg.send msg.random hackers
#hit the sinatra app to do the deploy
msg.http("http://localhost:9393/deploy/#{msg.match[1]}")
.get() (err, res, body) ->
if res.statusCode == 404
msg.send 'Something went horribly wrong'
else
msg.send 'Deployed like a boss'
msg.send 'http://hubot-assets.s3.amazonaws.com/fuck-yeah/3.gif'
else
msg.send 'Nope. I dont know what that is. Try deploying one of these: ' + repos.join(", ")
robot.respond /(what can you deploy?)/i, (msg) ->
msg.send 'I can deploy the shit out of ' + repos.join(", ")
require 'rubygems'
require 'sinatra'
get '/' do
"Leave this place"
end
#pass in the repo name and deploy that shit
get '/deploy/:name' do
bb = IO.popen("cd ~/Desktop/deploy_repos/"+params[:name]+"; git pull origin master; cap deploy")
b = bb.readlines
puts b.join
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment