Module: NurseAndrea::Deploy

Defined in:
lib/nurse_andrea/deploy.rb

Overview

Public: ship a deploy event to the NurseAndrea backend so the dashboard can render it as a vertical marker on time-series charts and as a chip in the recent-deploys strip.

Fire-and-forget: any failure (no token, network error, non-2xx) is logged in debug mode and swallowed so the host application never crashes from a deploy notification.

Constant Summary collapse

DESCRIPTION_LIMIT =
500

Class Method Summary collapse

Class Method Details

.call(version:, deployer: nil, environment: "production", description: nil) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/nurse_andrea/deploy.rb', line 12

def self.call(version:, deployer: nil, environment: "production", description: nil)
  return false unless NurseAndrea.config.valid?
  return false if version.to_s.strip.empty?

  payload = {
    version:     version.to_s,
    deployer:    deployer,
    environment: environment,
    description: description.is_a?(String) ? description[0, DESCRIPTION_LIMIT] : description,
    deployed_at: Time.now.utc.iso8601
  }.compact

  HttpClient.new.post(NurseAndrea.config.deploy_url, payload)
rescue => e
  NurseAndrea.debug("[NurseAndrea] deploy() error: #{e.class}: #{e.message}")
  false
end