98 lines
2.4 KiB
Makefile
98 lines
2.4 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 build test deploy pre-deploy post-deploy pre-local post-local upload pull start stop restart reload
|
|
|
|
self-update:
|
|
@- git submodule update --remote
|
|
|
|
deploy: build test upload pre-deploy pre-local pull start post-local post-deploy reload
|
|
|
|
build:
|
|
ifneq (,$(wildcard build.sh))
|
|
@- echo "\n### running build script"
|
|
@- ./build.sh || (echo "### build failed $$?"; exit 1)
|
|
else
|
|
@- echo "\n### no build script found"
|
|
endif
|
|
|
|
test:
|
|
ifneq (,$(wildcard test.sh))
|
|
@- echo "\n### running test script"
|
|
@- ./test.sh || (echo "### test failed $$?"; exit 1)
|
|
else
|
|
@- echo "\n### no test script found"
|
|
endif
|
|
|
|
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:
|
|
ifneq (,$(wildcard reload.sh))
|
|
@- echo "\n### reloading ..."
|
|
@- $(foreach host,$(DEPLOY_HOSTS), \
|
|
echo "### reloading service on $(host)"; \
|
|
ssh $(SSH_USER)@$(host) "cd $(DEPLOY_PATH)/$(DEPLOY_NAME); ./reload.sh"; \
|
|
)
|
|
else
|
|
@- echo "\n### no reload script found"
|
|
endif
|