Skip to content

Instantly share code, notes, and snippets.

@trevorturk
Created January 13, 2011 17:38
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save trevorturk/778234 to your computer and use it in GitHub Desktop.
Save trevorturk/778234 to your computer and use it in GitHub Desktop.
rake deploy and rake cache_assets for heroku
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
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