2022-11-03 08:48:22 +00:00
|
|
|
-include secrets.mk
|
|
|
|
include config.mk
|
2023-01-04 11:05:26 +00:00
|
|
|
-include $(DEPLOY_CONFIG_OVERRIDE)
|
2023-01-04 11:26:52 +00:00
|
|
|
include make-deploy/$(DEPLOY_TYPE).mk
|
2022-07-08 17:44:23 +00:00
|
|
|
|
2023-01-04 11:05:26 +00:00
|
|
|
.PHONY: self-update mandatory prerequisites prepare build test deploy pre-deploy post-deploy pre-local post-local upload pull start stop restart reload
|
2022-07-03 21:06:54 +00:00
|
|
|
|
2022-07-04 15:43:57 +00:00
|
|
|
self-update:
|
|
|
|
@- git submodule update --remote
|
2022-11-25 09:16:08 +00:00
|
|
|
|
2022-12-20 14:29:04 +00:00
|
|
|
deploy: mandatory prepare build test upload pre-deploy pre-local pull start post-local post-deploy reload
|
2022-12-20 14:27:50 +00:00
|
|
|
|
|
|
|
mandatory:
|
|
|
|
@- echo "\n### mandatory check"
|
|
|
|
ifndef MANDATORY-$(DEPLOY_TYPE)
|
|
|
|
$(error MANDATORY-$(DEPLOY_TYPE) is not defined)
|
|
|
|
endif
|
|
|
|
@ $(foreach var,$(MANDATORY), \
|
|
|
|
if test -z "${$(var)}"; then \
|
|
|
|
echo "Missing mandatory variable: $(var)"; \
|
|
|
|
exit 1; \
|
|
|
|
fi; \
|
|
|
|
)
|
2022-11-25 09:16:08 +00:00
|
|
|
|
2023-01-04 11:05:26 +00:00
|
|
|
prerequisites:
|
|
|
|
@- echo "\n### prerequisites ..."
|
|
|
|
@- ./prerequisites.sh
|
|
|
|
|
2022-12-20 12:39:22 +00:00
|
|
|
prepare:
|
|
|
|
@- echo "\n### preparing ..."
|
|
|
|
@- $(foreach host,$(DEPLOY_HOSTS), \
|
|
|
|
ssh $(SSH_USER)@$(host) "cd $(DEPLOY_PATH); mkdir $(DEPLOY_NAME)"; \
|
|
|
|
)
|
|
|
|
|
2022-11-25 09:16:08 +00:00
|
|
|
build:
|
|
|
|
ifneq (,$(wildcard build.sh))
|
|
|
|
@- echo "\n### running build script"
|
2022-11-25 09:56:54 +00:00
|
|
|
@ ./build.sh
|
2022-11-25 09:16:08 +00:00
|
|
|
else
|
|
|
|
@- echo "\n### no build script found"
|
|
|
|
endif
|
|
|
|
|
|
|
|
test:
|
|
|
|
ifneq (,$(wildcard test.sh))
|
|
|
|
@- echo "\n### running test script"
|
2022-11-25 09:56:54 +00:00
|
|
|
@ ./test.sh
|
2022-11-25 09:16:08 +00:00
|
|
|
else
|
|
|
|
@- echo "\n### no test script found"
|
|
|
|
endif
|
2022-07-03 21:06:54 +00:00
|
|
|
|
2022-09-29 08:25:43 +00:00
|
|
|
pre-deploy:
|
2022-11-03 08:48:22 +00:00
|
|
|
ifdef DEPLOY_HOSTS
|
2022-10-06 08:25:40 +00:00
|
|
|
@- echo "\n### running pre-deploy script(s)"
|
2022-09-29 08:25:43 +00:00
|
|
|
@- $(foreach host,$(DEPLOY_HOSTS), \
|
2022-11-15 12:58:13 +00:00
|
|
|
ssh $(SSH_USER)@$(host) "cd $(DEPLOY_PATH)/$(DEPLOY_NAME); sh pre-deploy.sh $(host); sh pre-deploy_$(host).sh"; \
|
2022-09-29 08:25:43 +00:00
|
|
|
)
|
2022-11-03 08:48:22 +00:00
|
|
|
endif
|
|
|
|
|
2022-09-29 08:25:43 +00:00
|
|
|
post-deploy:
|
2022-11-03 08:48:22 +00:00
|
|
|
ifdef DEPLOY_HOSTS
|
2022-10-06 08:25:40 +00:00
|
|
|
@- echo "\n### running post-deploy script(s)"
|
2022-09-29 08:25:43 +00:00
|
|
|
@- $(foreach host,$(DEPLOY_HOSTS), \
|
2022-11-15 12:58:13 +00:00
|
|
|
ssh $(SSH_USER)@$(host) "cd $(DEPLOY_PATH)/$(DEPLOY_NAME); sh post-deploy.sh $(host); sh post-deploy_$(host).sh"; \
|
2022-09-29 08:25:43 +00:00
|
|
|
)
|
2022-11-03 08:48:22 +00:00
|
|
|
endif
|
2022-07-04 07:47:18 +00:00
|
|
|
|
2022-10-05 14:02:54 +00:00
|
|
|
pre-local:
|
2022-11-03 08:48:22 +00:00
|
|
|
ifneq (,$(wildcard pre-local.sh))
|
2022-10-05 14:02:54 +00:00
|
|
|
@- echo "\n### running pre-local script"
|
2022-11-15 16:19:28 +00:00
|
|
|
@- $(foreach host,$(DEPLOY_HOSTS), \
|
2022-11-16 09:14:39 +00:00
|
|
|
./pre-local.sh $(host); \
|
2022-11-15 16:19:28 +00:00
|
|
|
)
|
2022-11-03 08:48:22 +00:00
|
|
|
else
|
|
|
|
@- echo "\n### no pre-local script found"
|
|
|
|
endif
|
|
|
|
|
2022-10-05 14:02:54 +00:00
|
|
|
post-local:
|
2022-11-03 08:48:22 +00:00
|
|
|
ifneq (,$(wildcard post-local.sh))
|
2022-10-06 08:25:40 +00:00
|
|
|
@- echo "\n### running post-local script"
|
2022-11-15 16:19:28 +00:00
|
|
|
@- $(foreach host,$(DEPLOY_HOSTS), \
|
2022-11-16 09:14:39 +00:00
|
|
|
./post-local.sh $(host); \
|
2022-11-15 16:19:28 +00:00
|
|
|
)
|
2022-11-03 08:48:22 +00:00
|
|
|
else
|
|
|
|
@- echo "\n### no post-local script found"
|
|
|
|
endif
|
|
|
|
|
2022-07-03 21:06:54 +00:00
|
|
|
upload:
|
2022-11-03 08:48:22 +00:00
|
|
|
ifdef DEPLOY_HOSTS
|
2022-07-03 21:06:54 +00:00
|
|
|
@- echo "\n### uploading files"
|
|
|
|
@- $(foreach host,$(DEPLOY_HOSTS), \
|
2022-07-08 17:44:23 +00:00
|
|
|
ssh $(SSH_USER)@$(host) "mkdir -p $(DEPLOY_PATH)/$(DEPLOY_NAME)"; \
|
2022-12-19 14:20:47 +00:00
|
|
|
rsync -rav --exclude '*~' --exclude '.git*' --exclude '*.swp' . $(SSH_USER)@$(host):$(DEPLOY_PATH)/$(DEPLOY_NAME); \
|
2022-07-03 21:06:54 +00:00
|
|
|
)
|
2022-11-03 08:48:22 +00:00
|
|
|
endif
|
2022-07-03 21:06:54 +00:00
|
|
|
|
2022-07-04 21:33:58 +00:00
|
|
|
pull: pull-$(DEPLOY_TYPE)
|
|
|
|
|
2022-07-03 21:06:54 +00:00
|
|
|
start: start-$(DEPLOY_TYPE)
|
|
|
|
|
2022-07-04 07:47:18 +00:00
|
|
|
stop: stop-$(DEPLOY_TYPE)
|
|
|
|
|
|
|
|
logs: logs-$(DEPLOY_TYPE)
|
2022-07-03 21:06:54 +00:00
|
|
|
|
2022-07-04 07:47:18 +00:00
|
|
|
restart: restart-$(DEPLOY_TYPE)
|
|
|
|
|
2022-11-21 16:09:39 +00:00
|
|
|
reload:
|
2022-11-25 09:16:08 +00:00
|
|
|
ifneq (,$(wildcard reload.sh))
|
|
|
|
@- echo "\n### reloading ..."
|
2022-11-21 16:09:39 +00:00
|
|
|
@- $(foreach host,$(DEPLOY_HOSTS), \
|
2022-11-24 12:36:25 +00:00
|
|
|
echo "### reloading service on $(host)"; \
|
2022-11-24 12:58:07 +00:00
|
|
|
ssh $(SSH_USER)@$(host) "cd $(DEPLOY_PATH)/$(DEPLOY_NAME); ./reload.sh"; \
|
2022-11-21 16:09:39 +00:00
|
|
|
)
|
2022-11-25 09:16:08 +00:00
|
|
|
else
|
|
|
|
@- echo "\n### no reload script found"
|
|
|
|
endif
|