Sha256: 27573d963a569e723369d76e514b64d01fde7abed2e4986417d465369c846714

Contents?: true

Size: 1.3 KB

Versions: 20

Compression:

Stored size: 1.3 KB

Contents

require "thor"
require "dddr"
require "terminal-table"
require "yaml"
require "toml-rb"
require "fileutils"
require "ostruct"
require "sucker_punch"
require "resend"

require_relative "harbr/version"
require_relative "harbr/container"
require_relative "harbr/job"

# Harbr module for managing containers, jobs, ports, and 2s
module Harbr
  DEFAULT_DIRECTORY = "/var/harbr/containers"
  DEFAULT_DIRECTORY_DATA_DIR = "#{DEFAULT_DIRECTORY}/.data"
  class Error < StandardError; end

  def self.send_notification(subject, body)
    Resend.api_key = ENV["RESEND_API_KEY"]

    params = {
      from: ENV["RESEND_FROM"],
      to: ENV["RESEND_TO"],
      subject: subject,
      html: body
    }

    Resend::Emails.send(params)
  rescue => e
    puts "Error sending notification: #{e.message}"
  end

  def self.notifiable(name, version)
    yield if block_given?
    send_notification("Harbr: #{name} deployed successfully", "<p>harbr: #{version} of #{name} deployed successfully</p>")
  rescue => e
    html_content = "<p>Error: #{e.message}</p>
              <p>#{e.backtrace.join("<br>")}</p>
              <p>harbr: #{version} of #{name} failed to deploy</p>"
    send_notification("Harbr: #{name} failed to deploy", html_content)
  end
end

Dddr.configure do |config|
  config.data_dir = Harbr::DEFAULT_DIRECTORY_DATA_DIR
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
harbr-0.1.62 lib/harbr.rb
harbr-0.1.61 lib/harbr.rb
harbr-0.1.60 lib/harbr.rb
harbr-0.1.59 lib/harbr.rb
harbr-0.1.58 lib/harbr.rb
harbr-0.1.57 lib/harbr.rb
harbr-0.1.56 lib/harbr.rb
harbr-0.1.55 lib/harbr.rb
harbr-0.1.54 lib/harbr.rb
harbr-0.1.53 lib/harbr.rb
harbr-0.1.52 lib/harbr.rb
harbr-0.1.50 lib/harbr.rb
harbr-0.1.49 lib/harbr.rb
harbr-0.1.48 lib/harbr.rb
harbr-0.1.47 lib/harbr.rb
harbr-0.1.46 lib/harbr.rb
harbr-0.1.45 lib/harbr.rb
harbr-0.1.44 lib/harbr.rb
harbr-0.1.43 lib/harbr.rb
harbr-0.1.42 lib/harbr.rb