Module: Coalmine::Capistrano

Defined in:
lib/coalmine/capistrano.rb

Class Method Summary collapse

Class Method Details

.setup(config) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/coalmine/capistrano.rb', line 5

def self.setup(config)
  config.load do
    after "deploy", "coalmine:deploy"
    
    namespace :coalmine do
      desc "Notify Coalmine of the deployment"
      task :deploy, :except => { :no_release => true } do
        environment = fetch(:rails_env, :production)
        author = ENV["USER"] || ENV["USERNAME"]
        rake = fetch(:rake, :rake)
        cmd = "cd #{config.current_release} && RAILS_ENV=#{environment} #{rake} coalmine:deployment[#{current_revision},#{author}]"
        logger.info "Notifying Coalmine of Deploy"
        if config.dry_run
          logger.info "Dry Run... Coalmine will not actually be notified"
        else
          run(cmd, :once => true)
        end
        
        logger.info "Coalmine notification completed."
      end
    end
  end
end