8 ms·
I use this pattern for my makefiles. First item is for "help", and it dynamically scrapes all the other commands (assuming format <command>: ## <description>).
by evolve-maz 1mo ago
I use this pattern for my makefiles. First item is for "help", and it dynamically scrapes all the other commands (assuming format <command>: ## <description>). So if I do 'make help' it'll list all the commands in the makefile without much extra work from me.
.PHONY: help
help: ## Show this help message
@grep -E '^[a-zA-Z_-]+:.?## .$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
@echo ""
@echo "Examples:"
@echo " make deploy"
@echo " make deploy-branch BRANCH=feature-x"
@echo " make deploy AUTO_START=true"
.PHONY: deploy
deploy: ## Deploy from current branch (default main) (use AUTO_START=true to restart service after)
@$(MAKE) _deploy BRANCH=$(git branch --show-current)