From 3d1006091d500f5f9d2eee5da5da3d1dd07e45f0 Mon Sep 17 00:00:00 2001 From: crowesn Date: Thu, 28 Sep 2023 11:16:13 -0400 Subject: [PATCH] add confirmation check to deploy --- config/deploy.rb | 29 +++++++++++++++++++++++++++++ config/deploy/production.rb | 5 +++++ 2 files changed, 34 insertions(+) diff --git a/config/deploy.rb b/config/deploy.rb index 38df7908..80967ca9 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -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 diff --git a/config/deploy/production.rb b/config/deploy/production.rb index 6cff9fa9..9bde32f6 100644 --- a/config/deploy/production.rb +++ b/config/deploy/production.rb @@ -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'