Created
January 21, 2012 17:21
-
-
Save foca/1653340 to your computer and use it in GitHub Desktop.
Rake task to synchronize assets to S3 (via asset_sync) and deploy to heroku, optionally migrating the database if that needs doing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is inspired by http://ckdake.com/comment/reply/362 | |
desc "Deploy ALL the targets" | |
task :deploy => ["deploy:assets", "deploy:heroku"] | |
namespace :deploy do | |
desc "Synchronize assets to S3" | |
task assets: [:environment, | |
:load_config, | |
"assets:precompile", | |
"assets:clean"] | |
desc "Push code to heroku and migrate the database, if needed" | |
task :heroku do | |
current_version = `git ls-remote heroku master | awk '{ print $1 }'`.chomp | |
schema_changed = `git log --pretty=%H #{current_version}.. -- db/schema.rb`.strip.present? | |
system "git push heroku" | |
exec "heroku run rake db:migrate" if schema_changed | |
end | |
task :load_config do | |
YAML.load_file("config/asset_sync.yml").fetch("defaults").each do |key, val| | |
ENV[key.upcase] = val.to_s | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment