Created
August 8, 2011 02:17
-
-
Save brianstorti/1131096 to your computer and use it in GitHub Desktop.
Simple deploy script
This file contains 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
# Just drop this code in lib/tasks/deploy.rake and now a simple '$ rake deploy' will push your changes live. | |
require 'net/ssh' | |
desc "Deploy site to production" | |
task :deploy => :environment do | |
host = 'yourhost.com' | |
user = 'username' | |
options = {:keys => '~/.ssh/keys/yourserver.pem'} | |
remote_path = '/path/to/rails_app' | |
commands = [ | |
"cd #{remote_path} && sudo git fetch", | |
"cd #{remote_path} && sudo git reset --hard origin/master", | |
"cd #{remote_path} && sudo bundle install", | |
"cd #{remote_path} && sudo touch tmp/restart.txt" | |
] | |
Net::SSH.start(host, user, options) do |ssh| | |
commands.each { |c| puts ssh.exec!(c) } | |
ssh.loop | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment