-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodedeploy.gnumakefile
More file actions
58 lines (48 loc) · 1.5 KB
/
codedeploy.gnumakefile
File metadata and controls
58 lines (48 loc) · 1.5 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
#
ifndef APPLICATION_NAME
$(error APPLICATION_NAME is not defined)
endif
ifndef AWS_PROFILE
$(error AWS_PROFILE is not defined)
endif
ifndef AWS_REGION
$(error AWS_REGION is not defined)
endif
ifndef S3_BUCKET
$(error S3_BUCKET is not defined)
endif
#
GIT_BRANCH!= git rev-parse --abbrev-ref HEAD
GIT_DIRTY!= git diff-files --quiet; echo $$?
GIT_HASH!= git rev-parse HEAD
#
NOW!= date -u +%Y%m%d-%H%M%S
S3_KEY= ${APPLICATION_NAME}/${GIT_BRANCH}-${NOW}-${GIT_HASH}
.PHONY: deploy deploy-force force-deploy setup-codedeploy-application setup-codedeploy-s3 setup-deploy _git_dirty
#
deploy:: _git_dirty deploy-force
@true
deploy-force::
aws deploy push \
--application-name "${APPLICATION_NAME}" \
--profile "${AWS_PROFILE}" \
--region "${AWS_REGION}" \
--s3-location "s3://${S3_BUCKET}/${S3_KEY}"
aws deploy create-deployment \
--application-name "${APPLICATION_NAME}" \
--deployment-group-name "${GIT_BRANCH}" \
--profile "${AWS_PROFILE}" \
--region "${AWS_REGION}" \
--s3-location bucket="${S3_BUCKET},key=${S3_KEY},bundleType=zip"
force-deploy:: deploy-force
@true
setup-codedeploy-application::
aws --profile "${AWS_PROFILE}" --region "${AWS_REGION}" deploy create-application --application-name "${APPLICATION_NAME}" || true
setup-codedeploy-s3::
aws --profile "${AWS_PROFILE}" --region "${AWS_REGION}" s3 mb "s3://${S3_BUCKET}/" || true
setup-deploy:: setup-codedeploy-s3 setup-codedeploy-application
@true
_git_dirty::
ifneq (${GIT_DIRTY}, 0)
$(error 'Git is dirty, stop deploying.')
endif