Created
January 13, 2011 17:38
-
-
Save trevorturk/778234 to your computer and use it in GitHub Desktop.
rake deploy and rake cache_assets for heroku
This file contains 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
desc "cache assets" | |
task :cache_assets => :environment do | |
paths = ['public/javascripts/all.js', 'public/stylesheets/all.css'] | |
puts "-----> caching assets..." | |
paths.each do |path| | |
puts "-----> #{path}" | |
end | |
paths.each do |path| | |
FileUtils.rm(path) if File.exist?(path) | |
end | |
ActionController::Base.perform_caching = true | |
session = ActionDispatch::Integration::Session.new(Rails.application) | |
session.get('/') | |
session.follow_redirect! | |
paths.each do |path| | |
if File.exist?(path) | |
system("git add #{path}") ? true : fail | |
end | |
end | |
if %x[git diff-index HEAD].present? | |
puts "-----> committing cached assets" | |
system("git commit -m 'cache_assets'") ? true : fail | |
else | |
puts "-----> nothing to commit" | |
end | |
puts "-----> done" | |
end |
This file contains 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
desc "cache assets, push to github, deploy to heroku, and notify hoptoad" | |
task :deploy => :environment do | |
puts "-----> running rake cache_assets" | |
system("rake cache_assets") ? true : fail | |
puts "-----> pushing to github" | |
system("git push origin master") ? true : fail | |
puts "-----> deploying to heroku" | |
system("git push heroku master") ? true : fail | |
puts "-----> notifying hoptoad" | |
system("rake hoptoad:deploy TO=production REVISION=`git rev-parse HEAD`") ? true : fail | |
puts "-----> done" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment