It seems that it’s a common mistake to attempt to deploy changes to production via Capistrano before you actually push the changes to an origin repository (github). This Capistrano task will warn you if you’re attempting to do such a thing. Please note that I didn’t author this task and I’ve forgotten who originally posted it, so just passing it along.

Edit: It seems that Darcy Laycock was the original author of this task. Thanks Darcy!


before "deploy", "deploy:check_revision"
 
namespace :deploy do
  desc "Make sure there is something to deploy"
  task :check_revision, :roles => [:web] do
    unless `git rev-parse HEAD` == `git rev-parse origin/master`
      puts ""
      puts "  \033[1;33m**************************************************\033[0m"
      puts "  \033[1;33m* WARNING: HEAD is not the same as origin/master *\033[0m"
      puts "  \033[1;33m**************************************************\033[0m"
      puts ""
 
      exit
    end
  end
end
Lee Hambley6 months ago

You could always make use of cap deploy:pending to do something similar, typically it will display the log.


before :deploy do
  exit(1) unless deploy.pending.default
end

deploy.pending.default should be false unless there is something to deploy.

HTH

Say your thing

Name:
Email:
URL:
$0.02: