Sha256: db1a096a54473bd09c39b989c4519a5ef2b6c5ac9fc74d9de27108394318b0c8

Contents?: true

Size: 1.33 KB

Versions: 6

Compression:

Stored size: 1.33 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"
require_relative "harbr/next/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

6 entries across 6 versions & 1 rubygems

Version Path
harbr-0.1.41 lib/harbr.rb
harbr-0.1.39 lib/harbr.rb
harbr-0.1.38 lib/harbr.rb
harbr-0.1.37 lib/harbr.rb
harbr-0.1.36 lib/harbr.rb
harbr-0.1.35 lib/harbr.rb