Skip to content

Commit

Permalink
Check current branch and it's match to deploy branch or not
Browse files Browse the repository at this point in the history
  • Loading branch information
naokazuterada committed May 26, 2020
1 parent b4aff90 commit 0e552ff
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,16 @@
# avoid losting old deploy history by force push
if Dir.exist?('build')
Dir.chdir 'build'
system 'git branch -u origin/production production'
system 'git pull origin'
current_branch = `git rev-parse --abbrev-ref HEAD`
current_branch.gsub!(/\n/, '') # pick up only branch name
puts "current_branch: #{current_branch}"
puts "DEPLOY_BRANCH: #{DEPLOY_BRANCH}"
if current_branch == DEPLOY_BRANCH
res = system 'git pull origin'
else
system "git co #{DEPLOY_BRANCH}"
system 'git pull origin'
end
Dir.chdir '..'
else
puts 'There isn\'t build dir yet, so do nothing.'
Expand Down

0 comments on commit 0e552ff

Please sign in to comment.