Skip to content

Instantly share code, notes, and snippets.

@ashrafuzzaman
Created March 11, 2014 11:07
Show Gist options
  • Save ashrafuzzaman/9483719 to your computer and use it in GitHub Desktop.
Save ashrafuzzaman/9483719 to your computer and use it in GitHub Desktop.
Faster capistrano deploy with skipping bundle install and asset pre-compilation using git
namespace :bundler do
desc "Install bundles into application"
task :install, :roles => [:app] do
from = source.next_revision(current_revision)
if capture("cd #{latest_release} && #{source.local.log(from)} Gemfile Gemfile.lock | wc -l").to_i > 0
run "cd #{latest_release} && #{try_sudo} bundle install --without test"
else
logger.info "Skipping Bundle install because there were no asset changes"
end
end
end
namespace :deploy do
namespace :assets do
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 %Q{cd #{latest_release} && #{rake} RAILS_ENV=#{rails_env} #{asset_env} assets:precompile}
else
logger.info "Skipping asset pre-compilation because there were no asset changes"
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment