make-deploy/Makefile

77 lines
1.9 KiB
Makefile

-include secrets.mk
include config.mk
include make-deploy/copy.mk
include make-deploy/docker.mk
include make-deploy/k8s.mk
include make-deploy/cron.mk
include make-deploy/kustomize.mk
include make-deploy/helm.mk
.PHONY: self-update create-contexts deploy pre-deploy post-deploy upload pull start stop restart reload
self-update:
@- git submodule update --remote
deploy: upload pre-deploy pre-local pull start post-local post-deploy
pre-deploy:
ifdef DEPLOY_HOSTS
@- echo "\n### running pre-deploy script(s)"
@- $(foreach host,$(DEPLOY_HOSTS), \
ssh $(SSH_USER)@$(host) "cd $(DEPLOY_PATH)/$(DEPLOY_NAME); sh pre-deploy.sh $(host); sh pre-deploy_$(host).sh"; \
)
endif
post-deploy:
ifdef DEPLOY_HOSTS
@- echo "\n### running post-deploy script(s)"
@- $(foreach host,$(DEPLOY_HOSTS), \
ssh $(SSH_USER)@$(host) "cd $(DEPLOY_PATH)/$(DEPLOY_NAME); sh post-deploy.sh $(host); sh post-deploy_$(host).sh"; \
)
endif
pre-local:
ifneq (,$(wildcard pre-local.sh))
@- echo "\n### running pre-local script"
@- $(foreach host,$(DEPLOY_HOSTS), \
./pre-local.sh $(host); \
)
else
@- echo "\n### no pre-local script found"
endif
post-local:
ifneq (,$(wildcard post-local.sh))
@- echo "\n### running post-local script"
@- $(foreach host,$(DEPLOY_HOSTS), \
./post-local.sh $(host); \
)
else
@- echo "\n### no post-local script found"
endif
upload:
ifdef DEPLOY_HOSTS
@- echo "\n### uploading files"
@- $(foreach host,$(DEPLOY_HOSTS), \
ssh $(SSH_USER)@$(host) "mkdir -p $(DEPLOY_PATH)/$(DEPLOY_NAME)"; \
rsync -rav --exclude '*~' --exclude '.git*' . $(SSH_USER)@$(host):$(DEPLOY_PATH)/$(DEPLOY_NAME); \
)
endif
pull: pull-$(DEPLOY_TYPE)
start: start-$(DEPLOY_TYPE)
stop: stop-$(DEPLOY_TYPE)
logs: logs-$(DEPLOY_TYPE)
restart: restart-$(DEPLOY_TYPE)
reload:
@- $(foreach host,$(DEPLOY_HOSTS), \
echo "$(host)"; \
ssh $(SSH_USER)@$(host) "cd $(DEPLOY_PATH)/$(DEPLOY_NAME); ./reload.sh; \
)