Created
June 15, 2012 10:57
-
-
Save jumski/2935861 to your computer and use it in GitHub Desktop.
simple capistrano multistage
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
# put this in deploy.rb, set proper values and remove all "set" and "role" calls that are here from the global namespace | |
desc "Run tasks in staging enviroment." | |
task :staging do | |
set :keep_releases, 3 | |
set :rvm_ruby_string, 'ruby-1.9.3-p0-falcon' | |
set :deploy_to, "/home/deploy/#{application}" | |
role :app, application | |
role :web, application | |
role :db, application, :primary => true | |
set :branch do | |
current_branch = %x[ git branch | grep ^* | awk {'print $2'} ].chomp | |
branch = Capistrano::CLI.ui.ask "Branch to deploy (make sure to push the branch first): [#{current_branch}] " | |
branch = current_branch if branch.empty? | |
branch | |
end | |
end | |
desc "Run tasks in production enviroment." | |
task :production do | |
# Prompt to make really sure we want to deploy into prouction | |
puts "\n\e[0;31m Are you REALLY sure you want to deploy to production?" | |
print " Enter y/N + enter to continue: " | |
proceed = STDIN.gets[0..0] rescue nil | |
exit(1) unless proceed == 'y' || proceed == 'Y' | |
puts "\e[0m\n" | |
# set production specific things | |
set :keep_releases, 30 | |
set :rvm_ruby_string, 'default' | |
set :deploy_to, "/home/deploy/app_name" | |
role :app, 'app_name' | |
role :web, 'app_name' | |
role :db, 'app_name', primary: true | |
set :branch do | |
default_branch = 'stable' | |
branch = Capistrano::CLI.ui.ask "Branch to deploy (make sure to push the branch first): [#{default_branch}] " | |
branch = default_branch if branch.empty? | |
branch | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment