Created
September 15, 2013 20:01
-
-
Save mrchilds/6573925 to your computer and use it in GitHub Desktop.
Simple hubot plugin
This file contains hidden or 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
# 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