Sha256: 98c895c0a1d9676b24f83438b29f7b72f0ff032a9973f3a7ab8043e44e0e8a88

Contents?: true

Size: 1.85 KB

Versions: 2

Compression:

Stored size: 1.85 KB

Contents

# Defines deploy:notify_pulse which will send information about the deploy to Pulse.
require 'capistrano'

module Pulse
  module Capistrano
    def self.load_into(configuration)
      configuration.load do
        after "deploy",            "pulse:deploy"
        after "deploy:migrations", "pulse:deploy"

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

if Capistrano::Configuration.instance
  Pulse::Capistrano.load_into(Capistrano::Configuration.instance)
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
projectlocker_pulse-1.0.0 lib/pulse/capistrano.rb
projectlocker_pulse-0.2.1 lib/pulse/capistrano.rb