class Ruboty::Capistrano::Actions::Deployment
Attributes
branch[R]
errors[R]
role[R]
Public Class Methods
new(role: , branch:)
click to toggle source
# File lib/ruboty/capistrano/actions/deployment.rb, line 9 def initialize(role: , branch:) @role = role @branch = branch @errors = [] end
Public Instance Methods
message_after_deploy()
click to toggle source
# File lib/ruboty/capistrano/actions/deployment.rb, line 26 def message_after_deploy "#{env}環境の#{role}にBRANCH:#{branch}をdeployしました" end
message_before_deploy()
click to toggle source
# File lib/ruboty/capistrano/actions/deployment.rb, line 22 def message_before_deploy "#{env}環境の#{role}にBRANCH:#{branch}をdeployします" end
run()
click to toggle source
# File lib/ruboty/capistrano/actions/deployment.rb, line 15 def run return unless validates deploy errors.empty? end
Private Instance Methods
cmd()
click to toggle source
# File lib/ruboty/capistrano/actions/deployment.rb, line 40 def cmd return @cmd if @cmd cmd_ary = [] cmd_ary << "cd #{repo_path}" version_file = "#{repo_path}/.ruby-version" if Ruboty::Capistrano.config.rbenv_root && File.exist?(version_file) cmd_ary << "RBENV_VERSION=\"$(cat #{version_file})\" rbenv exec bundle" cmd_ary << "RBENV_VERSION=\"$(cat #{version_file})\" rbenv exec bundle exec cap #{env} deploy BRANCH=#{branch}" else cmd_ary << 'bundle' cmd_ary << "bundle exec cap #{env} deploy BRANCH=#{branch}" end @cmd = cmd_ary.join(' && ') end
deploy()
click to toggle source
# File lib/ruboty/capistrano/actions/deployment.rb, line 55 def deploy Ruboty::Capistrano.logger.info("RUN: #{cmd}") out, err, status = Bundler.with_clean_env { Open3.capture3(cmd) } Ruboty::Capistrano.logger.info(out) return if err.empty? Ruboty::Capistrano.logger.error(err) errors << 'deploy中にエラーが発生しました' end
env()
click to toggle source
# File lib/ruboty/capistrano/actions/deployment.rb, line 32 def env Ruboty::Capistrano.config.env end
repo_path()
click to toggle source
# File lib/ruboty/capistrano/actions/deployment.rb, line 36 def repo_path Ruboty::Capistrano.config.local_repo_path[role] end