Skip to content

Instantly share code, notes, and snippets.

@priithaamer
Created June 19, 2011 11:01
Show Gist options
  • Star 21 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save priithaamer/1034070 to your computer and use it in GitHub Desktop.
Save priithaamer/1034070 to your computer and use it in GitHub Desktop.
Capistrano task to ask confirmation before deploying to production
task :ask_production_confirmation do
set(:confirmed) do
puts <<-WARN
========================================================================
WARNING: You're about to perform actions on production server(s)
Please confirm that all your intentions are kind and friendly
========================================================================
WARN
answer = Capistrano::CLI.ui.ask " Are you sure you want to continue? (Y) "
if answer == 'Y' then true else false end
end
unless fetch(:confirmed)
puts "\nDeploy cancelled!"
exit
end
end
before 'production', :ask_production_confirmation
@gonace
Copy link

gonace commented Mar 31, 2014

This isn't compatible with Capistrano 3.0?

@besi
Copy link

besi commented May 12, 2014

@gonace this is:

      set :confirmed, proc {
        puts <<-WARN

    ========================================================================
          WARNING: You're about to overwrite the production database
    ========================================================================

        WARN
        ask :answer, "Are you sure you want to continue? Type 'overwrite'"
        if fetch(:answer)== 'overwrite' then true else false end
      }.call

      unless fetch(:confirmed)
        puts "\nCancelled!"
        exit
      end

      run_locally do
        ask('bubu', 'bobo')
        with rails_env: :development do
          rake 'db:data:dump'
        end
      end

@besi
Copy link

besi commented May 12, 2014

Nice work BTW

@wacaw
Copy link

wacaw commented Oct 31, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment