feat: add --yes flag for non-interactive deployment

Adds --yes flag to deployment script to support automated/non-interactive deployments.

Changes:
- Added AUTO_YES flag parsing
- Modified all read -p prompts to check AUTO_YES flag
- Auto-confirms all prompts when --yes is used
- Maintains interactive behavior by default

Usage: ./scripts/deploy.sh --yes

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
TheFlow 2025-11-04 06:50:17 +13:00
parent f1e7834f46
commit cb453d89e0

View file

@ -18,6 +18,7 @@
## ./scripts/deploy.sh --force-cache # Force cache update regardless ## ./scripts/deploy.sh --force-cache # Force cache update regardless
## ./scripts/deploy.sh --restart # Restart service after deployment ## ./scripts/deploy.sh --restart # Restart service after deployment
## ./scripts/deploy.sh --dry-run # Show what would be deployed ## ./scripts/deploy.sh --dry-run # Show what would be deployed
## ./scripts/deploy.sh --yes # Auto-confirm all prompts (non-interactive)
## ##
set -e set -e
@ -41,6 +42,7 @@ FRONTEND_ONLY=false
FORCE_CACHE=false FORCE_CACHE=false
RESTART_SERVICE=false RESTART_SERVICE=false
DRY_RUN=false DRY_RUN=false
AUTO_YES=false
while [[ $# -gt 0 ]]; do while [[ $# -gt 0 ]]; do
case $1 in case $1 in
@ -60,9 +62,13 @@ while [[ $# -gt 0 ]]; do
DRY_RUN=true DRY_RUN=true
shift shift
;; ;;
--yes)
AUTO_YES=true
shift
;;
*) *)
echo -e "${RED}Unknown option: $1${NC}" echo -e "${RED}Unknown option: $1${NC}"
echo "Usage: $0 [--frontend-only] [--force-cache] [--restart] [--dry-run]" echo "Usage: $0 [--frontend-only] [--force-cache] [--restart] [--dry-run] [--yes]"
exit 1 exit 1
;; ;;
esac esac
@ -145,12 +151,14 @@ echo -e " ✓ File permissions checked"
if ! lsof -i :9000 >/dev/null 2>&1; then if ! lsof -i :9000 >/dev/null 2>&1; then
echo -e "${YELLOW} ⚠ WARNING: Local server not running on port 9000${NC}" echo -e "${YELLOW} ⚠ WARNING: Local server not running on port 9000${NC}"
echo " It's recommended to test changes locally before deployment." echo " It's recommended to test changes locally before deployment."
if [ "$DRY_RUN" = false ]; then if [ "$DRY_RUN" = false ] && [ "$AUTO_YES" = false ]; then
read -p " Continue anyway? (yes/NO): " continue_no_server read -p " Continue anyway? (yes/NO): " continue_no_server
if [ "$continue_no_server" != "yes" ]; then if [ "$continue_no_server" != "yes" ]; then
echo "Deployment cancelled. Start local server with: npm start" echo "Deployment cancelled. Start local server with: npm start"
exit 1 exit 1
fi fi
elif [ "$AUTO_YES" = true ]; then
echo " [--yes] Auto-continuing despite server warning"
fi fi
else else
echo -e " ✓ Local server running on port 9000" echo -e " ✓ Local server running on port 9000"
@ -168,12 +176,14 @@ fi
if [ ! -z "$UNCOMMITTED" ]; then if [ ! -z "$UNCOMMITTED" ]; then
echo -e "${YELLOW} ⚠ WARNING: Uncommitted changes detected:${NC}" echo -e "${YELLOW} ⚠ WARNING: Uncommitted changes detected:${NC}"
echo "$UNCOMMITTED" | sed 's/^/ /' echo "$UNCOMMITTED" | sed 's/^/ /'
if [ "$DRY_RUN" = false ]; then if [ "$DRY_RUN" = false ] && [ "$AUTO_YES" = false ]; then
read -p " Continue with uncommitted changes? (yes/NO): " continue_uncommitted read -p " Continue with uncommitted changes? (yes/NO): " continue_uncommitted
if [ "$continue_uncommitted" != "yes" ]; then if [ "$continue_uncommitted" != "yes" ]; then
echo "Deployment cancelled. Commit changes first." echo "Deployment cancelled. Commit changes first."
exit 1 exit 1
fi fi
elif [ "$AUTO_YES" = true ]; then
echo " [--yes] Auto-continuing with uncommitted changes"
fi fi
else else
echo -e " ✓ No uncommitted changes (excluding cache version files)" echo -e " ✓ No uncommitted changes (excluding cache version files)"
@ -286,12 +296,14 @@ fi
echo "" echo ""
if [ "$DRY_RUN" = false ]; then if [ "$DRY_RUN" = false ] && [ "$AUTO_YES" = false ]; then
read -p "Continue with deployment? (yes/NO): " confirm read -p "Continue with deployment? (yes/NO): " confirm
if [ "$confirm" != "yes" ]; then if [ "$confirm" != "yes" ]; then
echo "Deployment cancelled." echo "Deployment cancelled."
exit 0 exit 0
fi fi
elif [ "$AUTO_YES" = true ]; then
echo "[--yes] Auto-confirming deployment"
fi fi
echo "" echo ""
@ -337,10 +349,14 @@ if [ "$DRY_RUN" = true ]; then
exit 0 exit 0
fi fi
read -p "Proceed with actual deployment? (yes/NO): " confirm2 if [ "$AUTO_YES" = false ]; then
if [ "$confirm2" != "yes" ]; then read -p "Proceed with actual deployment? (yes/NO): " confirm2
echo "Deployment cancelled after dry-run." if [ "$confirm2" != "yes" ]; then
exit 0 echo "Deployment cancelled after dry-run."
exit 0
fi
else
echo "[--yes] Auto-proceeding with actual deployment"
fi fi
echo "" echo ""