Skip to content

Commit

Permalink
add confirmation check to deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
crowesn committed Sep 29, 2023
1 parent 81d2e17 commit 3d10060
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
29 changes: 29 additions & 0 deletions config/deploy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,32 @@
execute "cd #{fetch(:release_path)}/ && chmod a+x scripts/* && source scripts/check_ruby.sh"
end
end

namespace :deploy do
task :confirmation do
stage = fetch(:stage).upcase
branch = fetch(:branch)
puts <<-WARN
========================================================================
*** Deploying branch `#{branch}` to #{stage} server ***
WARNING: You're about to perform actions on #{stage} server(s)
Please confirm that all your intentions are kind and friendly
========================================================================
WARN
ask :value, "Sure you want to continue deploying `#{branch}` on #{stage}? (Y or Yes)"

unless fetch(:value).match(/\A(?!ye\b)(?i:yes|y)\z/)
puts "\nNo confirmation - deploy cancelled!"
exit
end
end
end

Capistrano::DSL.stages.each do |stage|
after stage, 'deploy:confirmation'
end
5 changes: 5 additions & 0 deletions config/deploy/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
ask(:username, nil)
ask(:password, nil, echo: false)
server 'libapps.libraries.uc.edu', user: fetch(:username), password: fetch(:password), port: 22, roles: %i[web app db]
ask(:value, 'Have you submitted and received an approved Change Management Request? (Y)')
if fetch(:value) != 'Y'
puts "\nDeploy cancelled!"
exit
end
set :deploy_to, '/opt/webapps/aaec'
after 'deploy:updating', 'ruby_update_check'
after 'deploy:updating', 'init_qp'
Expand Down

0 comments on commit 3d10060

Please sign in to comment.