Skip to content

Instantly share code, notes, and snippets.

@mrchilds
Created September 15, 2013 20:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrchilds/6573925 to your computer and use it in GitHub Desktop.
Save mrchilds/6573925 to your computer and use it in GitHub Desktop.
Simple hubot plugin
# Description:
# Deploy branches to staging.
#
# Commands:
# hubot deploy <branch> to <environment>
# hubot show branches
{spawn, exec} = require 'child_process'
module.exports = (robot) ->
# Deploy to staging
robot.respond /deploy @?([\w .-]+) to @?([\w .-]+)/i, (msg) ->
# Get branch
branch = msg.match[1]
# Get environment
environment = msg.match[2]
# Tell the user hubot is working on the request
msg.send "Preparing to deploy now..."
# Execute a fabric command
exec "cd #{RUN_FAB_FROM} && fab staging.#{cmd}:#{branch}", (err, stdout, stderr) ->
# Important - Tell users if something goes wrong
if err
msg.send "Sorry, something has gone wrong. Probably worth speaking to devops"
# Tell the user the branch has been deployed
else
msg.send "Success: #{branch} deployed to #{environment}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment