-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathdeploy_bundle.sh
68 lines (65 loc) · 2.91 KB
/
deploy_bundle.sh
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
#!/bin/sh
ORB_STR_APPLICATION_NAME="$(circleci env subst "${ORB_STR_APPLICATION_NAME}")"
ORB_STR_DEPLOYMENT_GROUP="$(circleci env subst "${ORB_STR_DEPLOYMENT_GROUP}")"
ORB_STR_BUNDLE_BUCKET="$(circleci env subst "${ORB_STR_BUNDLE_BUCKET}")"
ORB_STR_BUNDLE_KEY="$(circleci env subst "${ORB_STR_BUNDLE_KEY}")"
ORB_STR_REGION="$(circleci env subst "${ORB_STR_REGION}")"
ORB_STR_GET_DEPLOYMENT_GROUP_ARGUMENTS="$(circleci env subst "${ORB_STR_GET_DEPLOYMENT_GROUP_ARGUMENTS}")"
ORB_STR_BUNDLE_TYPE="$(circleci env subst "${ORB_STR_BUNDLE_TYPE}")"
ORB_STR_DEPLOY_BUNDLE_ARGUMENTS="$(circleci env subst "${ORB_STR_DEPLOY_BUNDLE_ARGUMENTS}")"
if [ -n "${ORB_STR_GET_DEPLOYMENT_GROUP_ARGUMENTS}" ]; then
set -- "$@" "${ORB_STR_GET_DEPLOYMENT_GROUP_ARGUMENTS}"
fi
if [ -n "${ORB_STR_DEPLOY_BUNDLE_ARGUMENTS}" ]; then
set -- "$@" "${ORB_STR_DEPLOY_BUNDLE_ARGUMENTS}"
fi
if [ -z ${ORB_STR_DEPLOYMENT_CONFIG+} ]; then
ID=$(aws deploy create-deployment \
--application-name "${ORB_STR_APPLICATION_NAME}" \
--deployment-group-name "${ORB_STR_DEPLOYMENT_GROUP}" \
--region "${ORB_STR_REGION}" \
--s3-location bucket="${ORB_STR_BUNDLE_BUCKET}",bundleType="${ORB_STR_BUNDLE_TYPE}",key="${ORB_STR_BUNDLE_KEY}"."${ORB_STR_BUNDLE_TYPE}" \
--profile "${ORB_STR_PROFILE_NAME}" \
--output text \
--query '[deploymentId]' "${ORB_STR_DEPLOY_BUNDLE_ARGUMENTS}")
else
ID=$(aws deploy create-deployment \
--application-name "${ORB_STR_APPLICATION_NAME}" \
--deployment-group-name "${ORB_STR_DEPLOYMENT_GROUP}" \
--deployment-config-name "${ORB_STR_DEPLOYMENT_CONFIG}" \
--region "${ORB_STR_REGION}" \
--s3-location bucket="${ORB_STR_BUNDLE_BUCKET}",bundleType="${ORB_STR_BUNDLE_TYPE}",key="${ORB_STR_BUNDLE_KEY}"."${ORB_STR_BUNDLE_TYPE}" \
--profile "${ORB_STR_PROFILE_NAME}" \
--output text \
--query '[deploymentId]' "${ORB_STR_DEPLOY_BUNDLE_ARGUMENTS}")
fi
STATUS=$(aws deploy get-deployment \
--deployment-id "$ID" \
--output text \
--profile "${ORB_STR_PROFILE_NAME}" \
--region "${ORB_STR_REGION}" \
--query '[deploymentInfo.status]' \
"${ORB_STR_GET_DEPLOYMENT_GROUP_ARGUMENTS}")
while [ "$STATUS" = "Created" ] || [ "$STATUS" = "InProgress" ] || [ "$STATUS" = "Pending" ] || [ "$STATUS" = "Queued" ] || [ "$STATUS" = "Ready" ]; do
echo "Status: $STATUS..."
STATUS=$(aws deploy get-deployment \
--deployment-id "$ID" \
--profile "${ORB_STR_PROFILE_NAME}" \
--region "${ORB_STR_REGION}" \
--output text \
--query '[deploymentInfo.status]'"${ORB_STR_GET_DEPLOYMENT_GROUP_ARGUMENTS}")
sleep 5
done
if [ "$STATUS" = "Succeeded" ]; then
EXITCODE=0
echo "Deployment finished."
else
EXITCODE=1
echo "Deployment failed!"
fi
aws deploy get-deployment --deployment-id "$ID" \
"${ORB_STR_GET_DEPLOYMENT_GROUP_ARGUMENTS}" \
--profile "${ORB_STR_PROFILE_NAME}" \
--region "${ORB_STR_REGION}" \
--profile "${ORB_STR_PROFILE_NAME}"
exit $EXITCODE