Skip to content

Instantly share code, notes, and snippets.

@nruth
Forked from trevorturk/cache_assets.rake
Created February 22, 2011 13:51
Show Gist options
  • Save nruth/838686 to your computer and use it in GitHub Desktop.
Save nruth/838686 to your computer and use it in GitHub Desktop.
#as seen in https://github.com/mooktakim/heroku_deployment
class AppTemplatesController < ApplicationController
def app
render :inline => "SUCCESS", :layout => 'master'
end
def cms
render :inline => "SUCCESS", :layout => 'cms_admin'
end
end
desc "cache assets"
task :cache_assets => :environment do
paths = ['public/javascripts/all.js', 'public/stylesheets/all.css', 'public/stylesheets/_cms.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('/caching/cms_templates')
session.get('/caching/app_templates')
paths.each do |path|
if File.exist?(path)
system("git add #{path}") ? true : fail
end
end
if paths.map {|path| %x[git status -s #{path}]}.any? {|p| p.present?}
puts "-----> committing cached assets"
system("git commit -m 'updating 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
@nruth
Copy link
Author

nruth commented Feb 22, 2011

work around devise auth by having a special route/controller setup for rendering particular layouts with no content

also checks that the expected files have been modified in git, not other unstaged changes, as the precondition for a new commit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment