Skip to content

Commit

Permalink
Add epi_deploy:set_branch task for manually set the Capistrano :branc…
Browse files Browse the repository at this point in the history
…h variable on deployment
  • Loading branch information
WilliamWFLee committed Oct 3, 2024
1 parent f9baca3 commit c174c8c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/capistrano/epi_deploy.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
load File.join(File.dirname(__FILE__), 'tasks', 'multi_customers.rb')
Dir.glob(File.join(File.dirname(__FILE__), 'tasks', '*.rb')).each { |f| require f }
21 changes: 21 additions & 0 deletions lib/capistrano/tasks/branches.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
if File.exist?('config/initializers/version.rb')
require_relative 'config/initializers/version'
end

namespace :epi_deploy do
task :set_branch do
branch = if ENV['BRANCH']
ENV['BRANCH']
elsif Object.const_defined?('LATEST_RELEASE_TAG')
LATEST_RELEASE_TAG
end

if branch.nil?
raise 'Cannot determine commit to deploy as BRANCH environment variable is not set and LATEST_RELEASE_TAG constant in version.rb could not be found'
end

set :branch, branch
end
end

before 'deploy:starting', 'epi_deploy:set_branch'

0 comments on commit c174c8c

Please sign in to comment.