diff --git a/Makefile b/Makefile index e8fec3c..49e002c 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,16 @@ +RED := \033[0;31m +GREEN := \033[0;32m +YELLOW := \033[0;33m +BLUE := \033[0;34m +MAGENTA := \033[0;35m +CYAN := \033[0;36m +WHITE := \033[0;37m +BOLD := \033[1m +RESET := \033[0m + .PHONY: default default: - @echo "Please specify a target to run, e.g., 'make live' for live deployment." + @echo "$(RED)Please specify a target to run, e.g., 'make live' for live deployment.$(RESET)" # Define a common rule to check if ALMANACK_ROOT is set .PHONY: check-activated @@ -11,14 +21,15 @@ endif # Define the 'live' target which will be triggered on 'make live' RSYNC_OPTS := -avz --delete --delete-after --filter='dir-merge,-n /.gitignore' -e "a-ssh" -DEST1 := boat:/var/local/www/www.almnck.com/ -DEST2 := amsterdam:/var/local/www/www.almnck.com/ -DEST3 := phoenix:/home/danny/www/www.almnck.com/ +DESTINATIONS := boat:/var/local/www/www.almnck.com/ dallas:/var/local/www/www.almnck.com/ sj:/var/local/www/www.almnck.com/ + .PHONY: live live: check-activated - @rsync $(RSYNC_OPTS) $(ALMANACK_ROOT)/web/ $(DEST1) - @rsync $(RSYNC_OPTS) $(ALMANACK_ROOT)/web/ $(DEST2) - @rsync $(RSYNC_OPTS) $(ALMANACK_ROOT)/web/ $(DEST3) + @test -d "$(ALMANACK_ROOT)/web" || (echo "ERROR: web directory not found" && exit 1) + @echo "Dry run preview:" + @$(foreach dest,$(DESTINATIONS),echo "$(BLUE)To $(dest)$(RESET)"; rsync $(RSYNC_OPTS) --dry-run $(ALMANACK_ROOT)/web/ $(dest);) + @read -p "Continue with deployment? (y/N): " confirm && [ "$$confirm" = "y" ] + @$(foreach dest,$(DESTINATIONS),echo "$(BLUE)To $(dest)$(RESET)"; rsync $(RSYNC_OPTS) $(ALMANACK_ROOT)/web/ $(dest);) .PHONY: test-doc test-doc: check-activated