Skip to content

Commit

Permalink
Merge pull request #225 from uclibs/218/interactive-deploy-check
Browse files Browse the repository at this point in the history
Add confirmation check to deploy
  • Loading branch information
Janell-Huyck authored Sep 29, 2023
2 parents 81d2e17 + f9234b0 commit 49e28ba
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(?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 or Yes)')
unless fetch(:value).match?(/\A(?i:yes|y)\z/)
puts "\nNo confirmation - deploy 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 49e28ba

Please sign in to comment.