Skip to content

Commit

Permalink
[#361] Implement deployment traceability and streamline notification …
Browse files Browse the repository at this point in the history
…process

- Modified 'all' target in Makefile to exclude 'info' and directly
  include 'notify', simplifying the deployment sequence.
- Introduced 'log-deployment' in info.mk for logging deployment details
  to /var/log/deployment.log. This includes capturing essential
  deployment metadata such as the environment, branch, commit, and
  versions of the deployed components, formatted with a timestamp and
  marked as INFO for clarity.
- Updated 'notify' target to depend on 'info' and 'log-deployment',
  ensuring comprehensive deployment information is shared and recorded.
  This includes deployment success notifications with detailed component
  versions and source information.
- Adjusted the format for logging deployment information to improve
  readability and consistency in monitoring tools.

These changes enhance the project's deployment traceability, allowing
for better tracking of deployments and easier debugging and auditing of
deployed versions.
  • Loading branch information
placek committed Mar 6, 2024
1 parent 6e9aa5b commit 988858a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion scripts/govtool/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ cardano_node_image_tag := 8.8.0-pre
cardano_db_sync_image_tag := sancho-4-0-0-fix-config

.PHONY: all
all: deploy-stack info notify
all: deploy-stack notify

.PHONY: deploy-stack
deploy-stack: upload-config push-backend push-frontend
Expand Down
13 changes: 10 additions & 3 deletions scripts/govtool/info.mk
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
# pipeline information
pipeline_url := $(shell echo $${PIPELINE_URL:-})
ifeq ($(PIPELINE_URL),)
ifeq ($(pipeline_url),)
pipeline_info := _Deployed from local machine._
else
pipeline_info := _Deployed from <$(pipeline_url)|GitHub>._
endif

deployment_log_file := /var/log/deployment.log

.PHONY: log-deployment
log-deployment:
@:$(call check_defined, cardano_network)
@:$(call check_defined, env)
ssh $(ssh_url) 'echo "$(shell date +'%Y-%m-%d %H:%M:%S%z') INFO: $(branch) ($(commit)); cardano-node $(cardano_node_image_tag); cardano-dbsync $(cardano_db_sync_image_tag); backend $(backend_image_tag); frontend $(frontend_image_tag); $(pipeline_url)" >> $(deployment_log_file)'

.PHONY: info
info:
@:$(call check_defined, cardano_network)
Expand All @@ -24,11 +32,10 @@ info:
@echo "+-----------"

.PHONY: notify
notify:
notify: info log-deployment
@:$(call check_defined, cardano_network)
@:$(call check_defined, env)
$(curl) -X POST https://slack.com/api/chat.postMessage\
-H "Authorization: Bearer $${GRAFANA_SLACK_OAUTH_TOKEN}" \
-H "Content-Type: application/json; charset=utf-8" \
--data "{ \"channel\":\"$${GRAFANA_SLACK_RECIPIENT}\", \"text\":\":rocket: *Deploy performed on \`$(env)\`*\n- from *branch* \`$(branch)\` (\`$(commit)\`),\n- using *Cardano Node* version \`$(cardano_node_image_tag)\`,\n- using *Cardano DB Sync* version \`$(cardano_db_sync_image_tag)\`,\n- using *GovTool backend* version \`$(backend_image_tag)\`,\n- using *Govtool frontend* version \`$(frontend_image_tag)\`.\n$(pipeline_info)\" }"

0 comments on commit 988858a

Please sign in to comment.