Skip to content

Instantly share code, notes, and snippets.

@JoshCheek
Created May 8, 2014 18:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JoshCheek/f63ca53fb118c1f96e1e to your computer and use it in GitHub Desktop.
Save JoshCheek/f63ca53fb118c1f96e1e to your computer and use it in GitHub Desktop.
Uhh... Is this how other people are dealing with private dependencies?
namespace :deploy do
desc 'Deploy the app to Heroku'
task :heroku do
inform = lambda { |message| puts "\e[37;44m#{message}\e[0m" }
deploy_branch = 'deploy'
current_branch = %x"git rev-parse --abbrev-ref HEAD".chomp
if current_branch == deploy_branch
inform.call "You're in the #{deploy_branch} branch, which we need to reset, please go elsewhere ;)"
exit 1
end
inform.call "Pulling Heroku's master branch into a local #{deploy_branch} branch"
sh "git branch -D #{deploy_branch}"
sh "git fetch heroku master:#{deploy_branch}"
sh "git checkout #{deploy_branch}"
inform.call "Merging master in the #{deploy_branch} branch"
sh "git merge master"
inform.call "Vendoring all our dependencies (we do this b/c some are stored in private github repos)"
sh "bundle package --all"
system "git diff --cached --exit-code"
if !$?.success?
inform.call "Committing the vendored changes"
sh "git add --all"
sh "git commit -m 'Vendor dependencies'"
else
inform.call "No changes to vendored dependencies"
end
inform.call "Run tests to make sure everything still works"
sh "env RAILS_ENV=test bundle exec rake db:drop db:create db:migrate db:seed" # reset test db
sh "bundle exec rake test:all"
inform.call "Pushing #{deploy_branch} branch to Heroku's master branch"
sh "git push heroku #{deploy_branch}:master"
inform.call "Running any migrations"
sh "heroku run rake db:migrate"
inform.call "Sending you to your previous branch"
sh "git checkout -"
inform.call "Opening the site so you can make sure its up and everything looks right"
sh "open http://enroll.turing.io"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment