class Renuo::Cli::Commands::ConfigureSemaphore
Attributes
Public Class Methods
Source
# File lib/renuo/cli/commands/configure_semaphore.rb, line 14 def initialize @project_name = File.basename(Dir.getwd) @slack_endpoint = "https://hooks.slack.com/services/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" end
Public Instance Methods
Source
# File lib/renuo/cli/commands/configure_semaphore.rb, line 53 def create_semaphore_deployment_targets system("sem create dt main -p #{project_name}") system("sem create dt develop -p #{project_name}") end
Source
# File lib/renuo/cli/commands/configure_semaphore.rb, line 43 def create_semaphore_notification File.write("tmp/notification.#{project_name}.yml", render("../templates/semaphore/notification.yml.erb")) system("sem create -f tmp/notification.#{project_name}.yml") FileUtils.rm("tmp/notification.#{project_name}.yml") end
Source
# File lib/renuo/cli/commands/configure_semaphore.rb, line 49 def create_semaphore_secrets system("sem create secret -p #{project_name} #{project_name}") end
Source
# File lib/renuo/cli/commands/configure_semaphore.rb, line 58 def render(template_file) file_path = File.join(File.dirname(__FILE__), template_file) semaphore_template = File.read(file_path) renderer = ERB.new(semaphore_template) renderer.result(binding) end
Source
# File lib/renuo/cli/commands/configure_semaphore.rb, line 19 def run # rubocop:disable Metrics/MethodLength return unless semaphore_cli_installed? FileUtils.mkdir_p(%w[.semaphore .semaphore/bin tmp]) write_or_warn(".semaphore/semaphore.yml", render("../templates/semaphore/semaphore.yml.erb")) %w[main develop].each do |environment| @environment = environment write_or_warn(".semaphore/#{environment}-deploy.yml", render("../templates/semaphore/semaphore-deploy.yml.erb")) end write_or_warn(".semaphore/bin/cache_restore", render("../templates/semaphore/bin/cache_restore.erb")) write_or_warn(".semaphore/bin/cache_store", render("../templates/semaphore/bin/cache_store.erb")) create_semaphore_notification create_semaphore_secrets create_semaphore_deployment_targets end
Source
# File lib/renuo/cli/commands/configure_semaphore.rb, line 37 def semaphore_cli_installed? semaphore_cli_installed = `sem context | grep '*'`.strip == "* renuo_semaphoreci_com" warn("You need to install and configure Semaphore CLI to run this command.") unless semaphore_cli_installed semaphore_cli_installed end
Source
# File lib/renuo/cli/commands/configure_semaphore.rb, line 65 def write_or_warn(file_path, content) if File.exist?(file_path) warn("#{file_path} exists already. I will not overwrite it.") else File.write(file_path, content) say("#{file_path} added.") end end