From a56ceb77d76a6fab9900893d4510d4d2d31774c8 Mon Sep 17 00:00:00 2001 From: Rasso Hilber Date: Thu, 28 Mar 2024 15:33:41 +0000 Subject: [PATCH] Allow deploy to production from non-main branch Show a prompt as a safeguard --- lib/functions.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/functions.sh b/lib/functions.sh index d409ec7..620a2b9 100644 --- a/lib/functions.sh +++ b/lib/functions.sh @@ -135,7 +135,14 @@ function validateProductionBranch() { # Validate the branch if [[ "${REMOTE_ENV}" == "production" && ! $CURRENT_BRANCH =~ $PRODUCTION_BRANCH ]]; then - logError "Branch ${BLUE}${CURRENT_BRANCH}${NC} not allowed in ${BLUE}production${NC}" + log "🚨 You are on the branch ${RED}${CURRENT_BRANCH}${NC}. Proceed deploy to ${BOLD}production${NORMAL}?" + read -r -p "[y/n] " PROMPT_RESPONSE + + # Exit early if not confirmed + if [[ "$PROMPT_RESPONSE" != "y" ]]; then + log "❌ Deploy to $PRETTY_REMOTE_ENV canceled" + exit + fi else logSuccess "Branch ${BLUE}${CURRENT_BRANCH}${NC} allowed in ${BLUE}${REMOTE_ENV}${NC}" fi