-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentrypoint.sh
67 lines (53 loc) · 1.67 KB
/
entrypoint.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
#!/bin/sh
set -e
if [ -z "$AWS_S3_BUCKET" ]; then
echo "AWS_S3_BUCKET is not set. Quitting."
exit 1
fi
if [ -z "$AWS_ACCESS_KEY_ID" ]; then
echo "AWS_ACCESS_KEY_ID is not set. Quitting."
exit 1
fi
if [ -z "$AWS_SECRET_ACCESS_KEY" ]; then
echo "AWS_SECRET_ACCESS_KEY is not set. Quitting."
exit 1
fi
if [ -z "$AWS_REGION" ]; then
echo "AWS_REGION is not set. Quitting."
exit 1
fi
if [ -z "$AWS_S3_LOCATION_KEY" ]; then
echo "AWS_S3_LOCATION_KEY is not set. Quitting."
exit 1
fi
if [ -z "$AWS_S3_BUNDLE_TYPE" ]; then
echo "AWS_S3_BUNDLE_TYPE is not set. Quitting."
exit 1
fi
if [ -z "$AWS_DEPLOYMENT_GROUP_NAME" ]; then
echo "AWS_DEPLOYMENT_GROUP_NAME is not set. Quitting."
exit 1
fi
if [ -z "$AWS_APPLICATION_NAME" ]; then
echo "AWS_APPLICATION_NAME is not set. Quitting."
exit 1
fi
# Create a dedicated profile for this action to avoid
# conflicts with other actions.
# https://github.com/jakejarvis/s3-sync-action/issues/1
aws configure --profile code-deploy-action <<-EOF > /dev/null 2>&1
${AWS_ACCESS_KEY_ID}
${AWS_SECRET_ACCESS_KEY}
${AWS_REGION}
text
EOF
sh -c "aws deploy create-deployment --profile code-deploy-action \
--region ${AWS_REGION} \
--application-name ${AWS_APPLICATION_NAME} \
--deployment-group-name ${AWS_DEPLOYMENT_GROUP_NAME} \
--s3-location bucket=${AWS_S3_BUCKET},bundleType=${AWS_S3_BUNDLE_TYPE},key=${AWS_S3_LOCATION_KEY} >> out.json"
if [ -z "$WAIT_FOR_BUILD" ]; then
exit 0
fi
export DEPLOY_ID=`head -2 out.json | tail -1 | cut -f4 -d\"`
aws deploy wait deployment-successful --profile code-deploy-action --region ${AWS_REGION} --deployment-id $DEPLOY_ID