-
Notifications
You must be signed in to change notification settings - Fork 14
/
Makefile
102 lines (81 loc) · 2.81 KB
/
Makefile
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
.PHONY: test lint build-docker docs build-docs
# Required parameters
flavor ?= null
version ?= null
# Dynamic parameters
prefix ?= $(shell hostname | tr "[:upper:]" "[:lower:]" | tr "." "-")
deployment_name ?= $(prefix)-$(flavor)
# Deployment outputs
bicep_outputs ?= $(shell az deployment sub show --name "$(deployment_name)" | yq '.properties.outputs')
job_name ?= $(shell echo $(bicep_outputs) | yq '.jobName.value')
rg_name ?= $(shell echo $(bicep_outputs) | yq '.rgName.value')
# Container App Job environment
container_specs ?= $(shell az containerapp job show --name "$(job_name)" --resource-group "$(rg_name)" | yq '.properties.template.containers[0]')
job_image ?= $(shell echo $(container_specs) | yq '.image')
job_env ?= $(shell echo $(container_specs) | yq '.env | map("\(.name)=\(.value // \"secretref:\" + .secretRef)") | .[]')
test:
@echo "➡️ Running Prettier"
npx --yes [email protected] --editorconfig --check .
@echo "➡️ Running Hadolint"
find . -name "Dockerfile*" -exec bash -c "echo 'File {}:' && hadolint {}" \;
@echo "➡️ Running Azure Bicep Validate"
az deployment sub validate \
--location westeurope \
--no-prompt \
--parameters test/bicep/lint.example.json \
--template-file src/bicep/main.bicep \
--verbose
lint:
@echo "➡️ Running Prettier"
npx --yes [email protected] --editorconfig --write .
@echo "➡️ Running Hadolint"
find . -name "Dockerfile*" -exec bash -c "echo 'File {}:' && hadolint {}" \;
@echo "➡️ Running Bicep lint"
az bicep lint \
--file src/bicep/main.bicep \
--verbose
deploy-bicep:
$(MAKE) deploy-bicep-iac
@echo "⏳ Wait for the Bicep output to be available"
sleep 10
$(MAKE) deploy-bicep-template
deploy-bicep-iac:
@echo "➡️ Decrypting Bicep parameters"
sops -d test/bicep/test.enc.json > test/bicep/test.json
@echo "➡️ Deploying Bicep"
az deployment sub create \
--location westeurope \
--name $(deployment_name) \
--no-prompt \
--parameters \
test/bicep/test.json \
imageFlavor=$(flavor) \
imageVersion=$(version) \
--template-file src/bicep/main.bicep
@echo "➡️ Cleaning up Bicep parameters"
rm test/bicep/test.json
deploy-bicep-template:
@echo "➡️ Starting template job"
az containerapp job start \
--env-vars $(job_env) AZP_TEMPLATE_JOB=1 \
--image $(job_image) \
--name $(job_name) \
--resource-group $(rg_name)
destroy-bicep:
@echo "➡️ Destroying Azure resources"
az group delete \
--name "$(rg_name)" \
--yes
integration:
$(MAKE) integration-run
$(MAKE) integration-cleanup
integration-run:
@bash test/integration-run.sh $(prefix) $(flavor) $(version) $(job_name) $(rg_name) github-actions
integration-cleanup:
@bash test/integration-cleanup.sh $(job_name) github-actions
docs:
cd docs && hugo server
build-docker:
@bash cicd/docker-build-local.sh
build-docs:
cd docs && hugo --gc --minify