Sha256: bb36678a574656534dabab99667e618f31f95bd429d5044aa1e2ad91ab09f33a
Contents?: true
Size: 1.66 KB
Versions: 1
Compression:
Stored size: 1.66 KB
Contents
require 'commander' require_relative './environments' class ConfigureSemaphore attr_accessor :project_name, :environment def initialize @project_name = File.basename(Dir.getwd) end def call return unless semaphore_cli_installed? FileUtils.mkdir_p('.semaphore') write_or_warn('.semaphore/semaphore.yml', render('templates/semaphore.yml.erb')) %w[master develop testing].each do |environment| @environment = environment write_or_warn(".semaphore/#{environment}-deploy.yml", render('templates/semaphore-deploy.yml.erb')) end create_semaphore_notification end private def semaphore_cli_installed? semaphore_cli_installed = `sem context`.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 def create_semaphore_notification system("sem create notifications #{project_name} "\ "--projects #{project_name} "\ '--branches "master,develop,testing" '\ "--slack-channels \"#project-#{project_name}\" "\ '--slack-endpoint "https://hooks.slack.com/services/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"') end 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 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 end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
renuo-cli-1.6.0 | lib/renuo/cli/app/configure_semaphore.rb |