module RatDeployer::Notifier
RatDeployer::Notifier
handles notifications to slack
Public Class Methods
deploy_properties()
click to toggle source
# File lib/rat_deployer/notifier.rb, line 60 def self.deploy_properties require 'socket' compose_config = RatDeployer::Cli.new.compose('config', silent: true) docker_config = YAML.safe_load(compose_config) images = docker_config['services'].map { |_s, c| c['image'] }.uniq.sort { env: RatDeployer::Config.env, user: ENV.fetch('USER'), hostname: Socket.gethostname, started_at: Time.now.to_s, images: images } end
notify(msg)
click to toggle source
# File lib/rat_deployer/notifier.rb, line 18 def self.notify(msg) return unless webhook_url return unless webhook_url slack_notifier.ping msg end
notify_deploy(title)
click to toggle source
# File lib/rat_deployer/notifier.rb, line 24 def self.notify_deploy(title) return unless webhook_url props = deploy_properties slack_notifier.post( text: title, attachments: [{ title: 'Deploy details', fields: props.map do |k, v| { title: k.to_s.titleize, value: k == :images ? v.join(' ยท ') : v, short: k != :images } end }] ) end
notify_deploy_end()
click to toggle source
# File lib/rat_deployer/notifier.rb, line 13 def self.notify_deploy_end return unless webhook_url notify_deploy "Ended deploy on #{RatDeployer::Config.env}" end
notify_deploy_start()
click to toggle source
# File lib/rat_deployer/notifier.rb, line 8 def self.notify_deploy_start return unless webhook_url notify_deploy "Starting deploy on #{RatDeployer::Config.env}" end
slack_notifier()
click to toggle source
# File lib/rat_deployer/notifier.rb, line 43 def self.slack_notifier return unless webhook_url @slack_notifier ||= begin Slack::Notifier.new( webhook_url, channel: '#alerts', username: 'rat-deployer' ) end end
webhook_url()
click to toggle source
# File lib/rat_deployer/notifier.rb, line 56 def self.webhook_url @webhook_url ||= RatDeployer::Config.all['slack_webhook_url'] end