Created
November 6, 2009 13:59
-
-
Save partydrone/227993 to your computer and use it in GitHub Desktop.
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
set :stages, %w(staging production) | |
set :default_stage, 'staging' | |
require 'capistrano/ext/multistage' | |
# repository elsewhere | |
set :scm, :git | |
set :repository, "[email protected]:Repositories/wavetronix.git" | |
set :ssh_options, { :forward_agent => true } | |
set :deploy_via, :remote_cache | |
namespace :deploy do | |
task :default do | |
set(:branch) do | |
br = Capistrano::CLI.ui.ask "What branch do you want to deploy?: ".downcase | |
raise 'Cannot deploy master branch to production.' if (stage.upcase == 'PRODUCTION') && br == 'master' | |
br | |
end | |
puts "*** Deploying to the #{stage.upcase} server!" | |
update | |
restart | |
# Clean up old deployments | |
deploy.cleanup | |
# Send deployment notification except, for the default stage | |
end | |
# override migrations task to inject branch | |
desc <<-DESC | |
Deploy and run pending migrations. This will work similarly to the \ | |
'deploy' task, but will also run any pending migrations (via the \ | |
'deploy:migrate' task) prior to updating the symlink. Note that the \ | |
update in this case it is not atomic, and transactions are not used, \ | |
because migrations are not guaranteed to be reversible. | |
DESC | |
task :migrations do | |
set :migrate_target, :latest | |
set(:branch) do | |
br = Capistrano::CLI.ui.ask 'What branch do you want to deploy?: '.downcase | |
raise 'Cannot deploy master branch to production.' if (stage.upcase == 'PRODUCTION') && br == 'master' | |
br | |
end | |
puts "*** Deploying to the #{stage.upcase} server!" | |
update_code | |
migrate | |
symlink | |
restart | |
# cleanup old deployments | |
deploy.cleanup | |
# Send deployment notification, except for the default stage | |
end | |
desc "Create symlink to shared files and folders on each release." | |
task :symlink_shared do | |
run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml" | |
run "ln -nfs #{shared_path}/assets #{release_path}/public/assets" | |
end | |
desc "Sync the public/assets directory." | |
task :assets do | |
system "rsync -vr --exclude='.DS_Store' public/assets #{user}@#{domain}:#{shared_path}/" | |
end | |
after "deploy:update_code", "deploy:symlink_shared" | |
end |
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
fiona:wavetronix aporter$ cap deploy | |
triggering start callbacks for `deploy' | |
* executing `multistage:ensure' | |
*** Defaulting to `staging' | |
* executing `staging' | |
* executing `deploy' | |
./config/deploy.rb:18:in `load': undefined method `upcase' for :staging:Symbol (NoMethodError) | |
from /Library/Ruby/Gems/1.8/gems/capistrano-2.5.8/lib/capistrano/configuration/execution.rb:139:in `instance_eval' | |
from /Library/Ruby/Gems/1.8/gems/capistrano-2.5.8/lib/capistrano/configuration/execution.rb:139:in `invoke_task_directly_without_callbacks' | |
from /Library/Ruby/Gems/1.8/gems/capistrano-2.5.8/lib/capistrano/configuration/callbacks.rb:27:in `invoke_task_directly' | |
from /Library/Ruby/Gems/1.8/gems/capistrano-2.5.8/lib/capistrano/configuration/execution.rb:89:in `execute_task' | |
from /Library/Ruby/Gems/1.8/gems/capistrano-2.5.8/lib/capistrano/configuration/execution.rb:101:in `find_and_execute_task' | |
from /Library/Ruby/Gems/1.8/gems/capistrano-2.5.8/lib/capistrano/cli/execute.rb:45:in `execute_requested_actions_without_help' | |
from /Library/Ruby/Gems/1.8/gems/capistrano-2.5.8/lib/capistrano/cli/execute.rb:44:in `each' | |
from /Library/Ruby/Gems/1.8/gems/capistrano-2.5.8/lib/capistrano/cli/execute.rb:44:in `execute_requested_actions_without_help' | |
from /Library/Ruby/Gems/1.8/gems/capistrano-2.5.8/lib/capistrano/cli/help.rb:19:in `execute_requested_actions' | |
from /Library/Ruby/Gems/1.8/gems/capistrano-2.5.8/lib/capistrano/cli/execute.rb:33:in `execute!' | |
from /Library/Ruby/Gems/1.8/gems/capistrano-2.5.8/lib/capistrano/cli/execute.rb:14:in `execute' | |
from /Library/Ruby/Gems/1.8/gems/capistrano-2.5.8/bin/cap:4 | |
from /usr/bin/cap:19:in `load' | |
from /usr/bin/cap:19 | |
fiona:wavetronix aporter$ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment