Created
March 11, 2014 20:15
-
-
Save codingfoo/9494072 to your computer and use it in GitHub Desktop.
Rails 4 Capistrano 2 local assets precompile
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
namespace :deploy do | |
namespace :assets do | |
desc 'Run the precompile task locally and rsync with shared' | |
task :precompile, :roles => :app, :except => { :no_release => true } do | |
system("bundle check"); exit if $? != 0 | |
system("RAILS_ENV=#{stage} bundle exec rake assets:precompile"); exit if $? != 0 | |
servers = find_servers :roles => :web, :except => { :no_release => true } | |
run <<-CMD.compact | |
cp -- #{shared_manifest_path.shellescape} #{current_path.to_s.shellescape}/assets_manifest#{File.extname(shared_manifest_path)} | |
CMD | |
run <<-CMD.compact | |
rm -- #{shared_manifest_path.shellescape} | |
CMD | |
servers.each { |server| system("rsync --recursive --times --rsh=ssh --compress --human-readable --progress public/assets #{user}@#{server}:#{shared_path} > /dev/null"); exit if $? != 0 } | |
system("RAILS_ENV=#{stage} bundle exec rake assets:clean") | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment