-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
58 lines (47 loc) · 2.15 KB
/
Copy pathMakefile
File metadata and controls
58 lines (47 loc) · 2.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
GREEN = \033[0;32m
BLUE = \033[0;34m
RED = \033[0;31m
NC = \033[0m
all: build
prepare:
@echo -e ":: $(GREEN)Preparing environment...$(NC)"
@echo -e ":: $(GREEN)Downloading go dependencies...$(NC)"
@go mod download \
&& echo -e "==> $(BLUE)Successfully downloaded go dependencies$(NC)" \
|| (echo -e "==> $(RED)Failed to download go dependencies$(NC)" && exit 1)
build: build-api build-worker
build-api:
@echo -e ":: $(GREEN)Building API...$(NC)"
@echo -e " -> Building API binary..."
@go build -o bin/api cmd/api/main.go && echo -e "==> $(BLUE)API build completed successfully$(NC)" || (echo -e "==> $(RED)API build failed$(NC)" && exit 1)
build-worker:
@echo -e ":: $(GREEN)Building Worker...$(NC)"
@echo -e " -> Building Worker binary..."
@go build -o bin/worker cmd/worker/main.go && echo -e "==> $(BLUE)Worker build completed successfully$(NC)" || (echo -e "==> $(RED)Worker build failed$(NC)" && exit 1)
run-api:
@echo -e ":: $(GREEN)Starting API...$(NC)"
@go build -o bin/api cmd/api/main.go && \
./bin/api \
&& echo -e "==> $(BLUE)Successfully shut down API$(NC)" \
|| (echo -e "==> $(RED)API failed to start$(NC)" && exit 1)
run-worker:
@echo -e ":: $(GREEN)Starting Worker...$(NC)"
@go build -o bin/worker cmd/worker/main.go && \
./bin/worker \
&& echo -e "==> $(BLUE)Successfully shut down Worker$(NC)" \
|| (echo -e "==> $(RED)Worker failed to start$(NC)" && exit 1)
clean:
@echo -e ":: $(GREEN)Cleaning binaries...$(NC)"
@rm -f bin/api bin/worker && echo -e "==> $(BLUE)Clean completed$(NC)" || (echo -e "==> $(RED)Clean failed$(NC)" && exit 1)
@rmdir bin 2>/dev/null || true
deploy:
@echo -e ":: $(GREEN)Sending deploy webhook request...$(NC)"
@PAYLOAD_FILE=webhook-payload.deploy.json; \
API_URL_VAL=$${API_URL:-http://localhost:8082}; \
./scripts/send-webhook.sh $$PAYLOAD_FILE $$API_URL_VAL $(DEPLOY_TOKEN)
cleanup:
@echo -e ":: $(GREEN)Sending cleanup webhook request...$(NC)"
@PAYLOAD_FILE=webhook-payload.cleanup.json; \
API_URL_VAL=$${API_URL:-http://localhost:8082}; \
./scripts/send-webhook.sh $$PAYLOAD_FILE $$API_URL_VAL $(DEPLOY_TOKEN)
.PHONY: all prepare build build-api build-worker run-api run-worker test deploy cleanup