Skip to content

Instantly share code, notes, and snippets.

@jwreagor
Created February 27, 2009 16:22
Show Gist options
  • Save jwreagor/71547 to your computer and use it in GitHub Desktop.
Save jwreagor/71547 to your computer and use it in GitHub Desktop.
begin
require 'capistrano_colors'
rescue LoadError
puts "Cannot load Capistrano Colors gem"
end
set :rails_env, ENV['rails_env'] || ENV['RAILS_ENV'] || 'beta'
set :extra_deploys, 'config/deployments/'
set :application, 'appname'
set :user, application
set :domain, 'deploy_to.server.com'
set :deploy_via, :copy
set :copy_cache, true
set :copy_exclude, [".git"]
set :scm, :git
set :scm_username, ENV['USER']
set :repository, "#{scm_username}@git.companycoinc.com:#{application}.git"
set :branch, "master"
role :app, domain
role :web, domain
role :db, domain, :primary => true
set :use_sudo, false
set :git_shallow_clone, 1
default_run_options[:pty] = true
namespace :deploy do
# NOTE: Verbose so that others know what this deployment entails
desc 'default redeployment method'
task :default do
git.tag
update
migrate
restart
company.send_tweet
end
desc "Restarting mod_rails with restart.txt"
task :restart, :roles => :app, :except => { :no_release => true } do
run "touch #{current_path}/tmp/restart.txt"
end
[:start, :stop].each do |t|
desc "#{t} task is a no-op with mod_rails"
task t, :roles => :app do ; end
end
end
desc 'Git related recipes'
namespace :git do
# NOTE: Not used in this deployment, but can be added after update (like wise, rake gems:install)
desc 'pulls down submodules after performing a deployment'
task :submodules do
run "cd #{deploy_to}/current &&
git submodule init &&
git submodule update"
end
desc "Tag the current branch for a release"
task :tag do
timestamp = Time.now.strftime("%Y%m%d%H%M%S")
tag_name = ENV['TAG'] || "#{timestamp}-REL"
system "git tag -a -m 'Tagged for release on #{timestamp}' #{tag_name}"
system "git push --tags"
end
end
# Loads environment specific cap tasks, namespaces and overrides anything above!
puts extra_deploys && File.exist?(extra_deploys+rails_env+".rb") ?
("Loaded #{extra_deploys+rails_env}.rb" if load extra_deploys+rails_env) :
"Could not find #{extra_deploys+rails_env}.rb"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment