Last Updated: February 25, 2016
·
797
· kibenimatik

Quick assets deploy with capistrano

namespace :assets do
  desc "Precompile assets"
  task :precompile, :roles => :web, :except => { :no_release => true } do
    from = source.next_revision(current_revision)
    if capture("cd #{latest_release} && #{source.local.log(from)} vendor/assets/ app/assets/ | wc -l").to_i > 0
      run_locally("rm -rf public/assets/*")
      run_locally("bundle exec rake assets:precompile")
      run_locally("rsync --recursive --times --rsh=ssh --compress --human-readable --progress public/assets #{domain}:#{shared_path}")
      run_locally("rm -rf public/assets/*")
    else
      logger.info "Skipping asset pre-compilation because there were no asset changes"
    end
  end
end