Module: ProjectlockerErrata::Capistrano

Defined in:
lib/projectlocker_errata/capistrano.rb

Class Method Summary collapse

Class Method Details

.load_into(configuration) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/projectlocker_errata/capistrano.rb', line 6

def self.load_into(configuration)
  configuration.load do
    after "deploy",            "projectlocker_errata:deploy"
    after "deploy:migrations", "projectlocker_errata:deploy"

    namespace :projectlocker_errata do
      desc "        Notify ProjectlockerErrata of the deployment by running the notification on the REMOTE machine.\n          - Run remotely so we use remote API keys, environment, etc.\n      DESC\n      task :deploy, :except => { :no_release => true } do\n        rails_env = fetch(:rails_env, \"production\")\n        projectlocker_errata_env = fetch(:projectlocker_errata_env, fetch(:rails_env, \"production\"))\n        local_user = ENV['USER'] || ENV['USERNAME']\n        executable = RUBY_PLATFORM.downcase.include?('mswin') ? fetch(:rake, 'rake.bat') : fetch(:rake, 'rake')\n        directory = configuration.current_release\n        notify_command = \"cd \#{directory}; \#{executable} RAILS_ENV=\#{rails_env} projectlocker_errata:deploy TO=\#{projectlocker_errata_env} REVISION=\#{current_revision} REPO=\#{repository} USER=\#{local_user}\"\n        notify_command << \" DRY_RUN=true\" if dry_run\n        notify_command << \" API_KEY=\#{ENV['API_KEY']}\" if ENV['API_KEY']\n        logger.info \"Notifying ProjectlockerErrata of Deploy (\#{notify_command})\"\n        if configuration.dry_run\n          logger.info \"DRY RUN: Notification not actually run.\"\n        else\n          result = \"\"\n          run(notify_command, :once => true) { |ch, stream, data| result << data }\n          # TODO: Check if SSL is active on account via result content.\n        end\n        logger.info \"ProjectlockerErrata Notification Complete.\"\n      end\n    end\n  end\nend\n"