-
-
Save Epictetus/1112048 to your computer and use it in GitHub Desktop.
Simple Rails Deployments with Net/SSH
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
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