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