Last active
March 2, 2018 03:26
-
-
Save ibanez270dx/91ac37cd252aba531cd66065283f5a6c to your computer and use it in GitHub Desktop.
Capistrano Deploy Confirmation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /lib/capistrano/tasks/confirmation.cap | |
namespace :deploy do | |
task :confirmation do | |
color = case fetch(:stage) | |
when :production then 31 | |
when :staging then 33 | |
else 34 | |
end | |
puts <<~WARN | |
\e[1mYou are about to deploy branch \e[#{color}m#{fetch(:branch)}\e[0m\e[1m to \e[#{color}m#{fetch(:stage)}\e[0m | |
\e[31mAre you sure you want to continue?\e[0m | |
WARN | |
ask :value, "Y/n" | |
unless %w(Y y).include?(fetch(:value)) | |
puts "\nDeploy cancelled!" | |
exit | |
end | |
if fetch(:stage) == :production | |
puts <<~WARN | |
\e[1m\e[41mAre you \e[3mREALLY\e[23m sure you want to continue?\e[22m\e[0m | |
WARN | |
ask :value, "Y/n" | |
unless %w(Y y).include?(fetch(:value)) | |
puts "\nDeploy cancelled!" | |
exit | |
end | |
end | |
end | |
end | |
Capistrano::DSL.stages.each do |stage| | |
after stage, 'deploy:confirmation' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment