Skip to content

Instantly share code, notes, and snippets.

@Hermanverschooten
Created August 10, 2014 14:41
Show Gist options
  • Save Hermanverschooten/5b3471d17b8ced329832 to your computer and use it in GitHub Desktop.
Save Hermanverschooten/5b3471d17b8ced329832 to your computer and use it in GitHub Desktop.
Skip asset compilation in Capistrano 3 if no assets have changed since last deploy
namespace :deploy do
Rake::Task["deploy:compile_assets"].clear_actions
task :compile_assets => [:set_rails_env] do
run_locally do
if capture("git --no-pager diff #{fetch(:previous_revision)} #{fetch(:current_revision)} app/assets vendor/assets").empty?
info "Skipping assets compilation"
else
invoke 'deploy:assets:precompile'
invoke 'deploy:assets:backup_manifest'
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment