This repository has been archived by the owner on May 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
60 lines (48 loc) · 2.3 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
RELEASE_VERSION = 0.1.0
ifdef CI
PROFILE_REQUIRED=profile
endif
docs: .env
docker-compose run --rm terraform-utils terraform-docs markdown document . > README.md
PHONY: docs
format: .env
docker-compose run --rm terraform-utils terraform fmt -recursive .
PHONY: format
formatCheck: .env
docker-compose run --rm terraform-utils terraform fmt -recursive -check -diff .
PHONY: formatCheck
init: .env $(PROFILE_REQUIRED)
docker-compose run --rm terraform-utils terraform init tests
PHONY: init
plan: .env $(PROFILE_REQUIRED) init
docker-compose run --rm terraform-utils terraform plan tests
PHONY: plan
apply: .env $(PROFILE_REQUIRED) init
docker-compose run --rm terraform-utils terraform apply -auto-approve tests
PHONY: apply
destroy: .env $(PROFILE_REQUIRED) init
docker-compose run --rm terraform-utils terraform destroy -auto-approve tests
PHONY: destroy
tag:
git tag -a $(RELEASE_VERSION) -m ''
git push origin $(RELEASE_VERSION)
PHONY: tag
publish: .env
docker-compose run --rm envvars ensure --tags publish
git fetch --all
git remote add github https://$(GIT_USERNAME):$(GIT_PASSWORD)@github.com/cmdlabs/$(CI_PROJECT_NAME)
git checkout master
git pull origin master
git push --follow-tags github master || git fetch --unshallow origin master; git push --follow-tags github master
docker-compose run --rm terraform-utils curl -X POST -H 'Content-type: application/json' --data '{"text":"A new commit has been published to Github\nProject: $(CI_PROJECT_NAME)\nRef: $(CI_COMMIT_REF_NAME)\nDiff: https://github.com/cmdlabs/$(CI_PROJECT_NAME)/commit/$(CI_COMMIT_SHA)"}' $(GIT_PUBLISHING_WEBHOOK)
PHONY: publish
profile: .env
docker-compose run --rm envvars ensure --tags profile
docker-compose run --rm aws sh -c 'aws configure set credential_source Ec2InstanceMetadata --profile $${AWS_PROFILE_NAME}'
docker-compose run --rm aws sh -c 'aws configure set role_arn arn:aws:iam::$${AWS_ACCOUNT_ID}:role/$${AWS_ROLE_NAME} --profile $${AWS_PROFILE_NAME}'
docker-compose run --rm aws aws configure set credential_source Ec2InstanceMetadata --profile cmdlabtf-tfbackend
docker-compose run --rm aws aws configure set role_arn arn:aws:iam::$(AWS_ACCOUNT_ID_MASTER):role/gitlab_runner --profile cmdlabtf-tfbackend
.env:
touch .env
docker-compose run --rm envvars validate
docker-compose run --rm envvars envfile --overwrite