Eliminate Typing Repetitive Commands, such as Deploying Rails Apps with Capistrano and Git
Posted by Daniel on 04/01/2009Deploying with Capistrano & Git
If you aren't using capistrano for deployment, you are wasting your time. It speeds up the deployment process in unmeasurable amounts. It basically automates deployment, trimming the commands you type by about 5000%. Git makes version control easy.
As cool as it is, I still find myself typing:
dwestendorf$ git add . dwestendorf$ git commit -m "blah" dwestendorf$ git push origin dwestendorf$ cap deploy
While this does save untold amounts of time, I want it to be faster. I've thrown together a quick bash script to accomplish all the typing. It should be noted that this is one of a million ways to do this, and that you could apply this to a million other commands and processes.
The script
#!/bin/bash
echo "Deploying app...."
git add .
git status
echo "Enter commit comment: "
read comment
git commit -m "$comment"
git push origin master
cap deploy
A Ruby Version
#!/usr/bin/ruby
comment = ARGV.first
system("git add .")
system("git commit -m \"")
puts "Pushing commit to origin..."
system("git push origin")
puts ("Deploying")
system("cap deploy")
Making it work
- Save the above script to a file. I called mine rdeploy
- Execute the following command via the Terminal:
dwestendorf$ chmod +x rdeploy
- Now move the file into one of your executable paths. Find this by typing:
dwestendorf$ $PATH
The paths will be separated by a colon. - Move your script file (rdeploy) to one of those directories. Mine was "/Users/dwestendorf/Utils/"
- I then had to execute the following command in my home directory:
dwestendorf$ . .bash_login
You're Done
Now, if you have capistrano and git set up correctly, you can execute rdeploy in the root path of your Rails app. It will prompt you for a commit comment, and display all the output of the commands to you! Simple, short, and sweet!

No comments yet.