class HerokuSan::Deploy::Tagged
Public Instance Methods
deploy()
click to toggle source
Calls superclass method
# File lib/heroku/tagged/tagged_deploy.rb, line 65 def deploy get_changes say 'Checking for precompiled assets' if File.exist?(::Rails.root.join('public/assets/manifest.yml')) say 'Found manifest.yml. Precompile assets.' say 'Checking if we need to precompile' if deploying_assets? say 'Deploying new assets, precompiling...' precompile_assets else say 'Not deploying new assets, skipped precompile.' end end enable_maintenance_if_needed # Do the deploy super post_changes @stage.tag_repo say 'Warming up the Heroku dynos' sh "curl -o /dev/null http://#{@stage.app}.herokuapp.com" end
deploying_assets?()
click to toggle source
# File lib/heroku/tagged/tagged_deploy.rb, line 22 def deploying_assets? if @file_changes.index('app/assets') true else false end end
enable_maintenance_if_needed()
click to toggle source
# File lib/heroku/tagged/tagged_deploy.rb, line 15 def enable_maintenance_if_needed if @file_changes.index('db/migrate') || @file_changes.index('db/seeds.rb') say 'Migrations found -- enabling maintenance mode...' heroku("maintenance:on -a #{@stage.app}") end end
get_changes()
click to toggle source
# File lib/heroku/tagged/tagged_deploy.rb, line 4 def get_changes say 'Getting current tags...' `git fetch --tags` say 'Fetching current state.' `git fetch #{@stage.name}` previous_sha_commit = `git rev-parse HEAD`.strip say 'Deploying these changes:' puts `git log --pretty=format:"* %s" #{@stage.name}/master..#{previous_sha_commit}` @file_changes = `git diff --name-only #{previous_sha_commit} #{@stage.name}/master` end
post_changes()
click to toggle source
# File lib/heroku/tagged/tagged_deploy.rb, line 30 def post_changes if @file_changes.index('db/migrate') say 'Running migrations, as there are new ones added.' heroku("run rake db:migrate -a #{@stage.app}") end if @file_changes.index('db/seeds.rb') say 'It looks like you adjusted or created the seeds.rb file.' say 'Running the rake db:seed command now...' heroku("run rake db:seed -a #{@stage.app}") end if @file_changes.index('db/migrate') || @file_changes.index('db/seeds.rb') say 'Disabling the maintenance mode.' heroku("maintenance:off -a #{@stage.app}") say 'Restarting...' heroku("restart -a #{@stage.app}") end end
precompile_assets()
click to toggle source
# File lib/heroku/tagged/tagged_deploy.rb, line 48 def precompile_assets `rake RAILS_ENV=production RAILS_GROUP=assets assets:precompile` `rake assets:clean_expired` if in_gemfile?('turbo-sprockets-rails3') if system('git diff --cached --exit-code') == false || system('git diff --exit-code') == false `git add -A .` `git gc` `git commit -m 'assets precompiled'` `git push` else say 'No assets changed, no extra commit needed.' end end
say(text)
click to toggle source
# File lib/heroku/tagged/tagged_deploy.rb, line 61 def say(text) puts "[#{Time.now.strftime('%H:%M:%S')}][#{@stage.name}] #{text}" end
Private Instance Methods
heroku(command)
click to toggle source
Executes a command in the Heroku
Toolbelt
# File lib/heroku/tagged/tagged_deploy.rb, line 101 def heroku(command) system("GEM_HOME='' BUNDLE_GEMFILE='' GEM_PATH='' RUBYOPT='' /usr/local/heroku/bin/heroku #{command}") end
in_gemfile?(reg)
click to toggle source
# File lib/heroku/tagged/tagged_deploy.rb, line 94 def in_gemfile?(reg) content = File.read(::Rails.root.join('Gemfile')) !content.index(reg).nil? end