-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
47 lines (40 loc) · 1.43 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
PKG = chatbot.zip
ZIP := zip
ZIP_ARGS := -9rq
STACK := chatbot
BUCKET := grogan-splorgin
all: test
$(PKG):
rm -f $(PKG)
cd python && \
pip install --quiet -r requirements.txt -t . && \
$(ZIP) $(ZIP_ARGS) ../$(PKG) .
publish: $(PKG)
$(eval ETAG=$(shell aws s3api head-object --bucket $(BUCKET) --key $(PKG) --query ETag --output text | sed -e 's/"//g' ))
$(eval MD5=$(shell md5sum $(PKG) | awk '{ print $$1 }' ))
if [ "x$(ETAG)" = "x$(MD5)" ]; then \
echo "No changes to the code, not updating"; \
else \
aws s3 cp $(PKG) s3://$(BUCKET)/; \
fi
$(eval VERSION=$(shell aws s3api head-object --bucket $(BUCKET) --key $(PKG) --query VersionId --output text ))
stack: publish
if aws cloudformation describe-stacks --stack-name $(STACK) >/dev/null 2>&1; then \
aws cloudformation update-stack \
--capabilities CAPABILITY_IAM \
--stack-name chatbot \
--parameters ParameterKey=CodeVersion,ParameterValue=$(VERSION) \
--template-body file://cloudformation/chatbot.yml || exit 0 && \
aws cloudformation wait stack-update-complete --stack-name $(STACK); \
else \
aws cloudformation create-stack \
--capabilities CAPABILITY_IAM \
--stack-name $(STACK) \
--parameters ParameterKey=CodeVersion,ParameterValue=$(VERSION) \
--template-body file://cloudformation/chatbot.yml && \
aws cloudformation wait stack-create-complete \
--stack-name $(STACK); \
fi
test: stack
cd tests && ./run_tests $(STACK)
.PHONY: $(PKG)