Skip to content

Commit 135cbf4

Browse files
committed
feat: validate codedeploy mode & register revision
1 parent 92cadd1 commit 135cbf4

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

deploy.sh

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ GREEN='\033[0;32m'
77
ORANGE='\033[0;33m'
88
BLUE='\033[0;34m'
99

10+
# 0) Validation
11+
if [ "$INPUT_CODEDEPLOY_MODE" != "deploy" ] && [ "$INPUT_CODEDEPLOY_MODE" != "register" ]; then
12+
echo "::error::$INPUT_CODEDEPLOY_MODE was not 'deploy' or 'register'."
13+
exit 1;
14+
fi
15+
1016
# 1) Load our permissions in for aws-cli
1117
export AWS_ACCESS_KEY_ID=$INPUT_AWS_ACCESS_KEY
1218
export AWS_SECRET_ACCESS_KEY=$INPUT_AWS_SECRET_KEY
@@ -81,10 +87,24 @@ function deployRevision() {
8187
--s3-location bucket="$INPUT_S3_BUCKET",bundleType=zip,eTag="$ZIP_ETAG",key="$INPUT_S3_FOLDER"/"$ZIP_FILENAME" > /dev/null 2>&1
8288
}
8389

84-
echo -e "$BLUE Deploying to $NO_COLOR$INPUT_CODEDEPLOY_GROUP.";
85-
deployRevision
90+
function registerRevision() {
91+
aws deploy register-application-revision \
92+
--application-name "$INPUT_CODEDEPLOY_NAME" \
93+
--description "$GITHUB_REF - $GITHUB_SHA" \
94+
--s3-location bucket="$INPUT_S3_BUCKET",bundleType=zip,eTag="$ZIP_ETAG",key="$INPUT_S3_FOLDER"/"$ZIP_FILENAME" > /dev/null 2>&1
95+
}
96+
97+
if [ "$INPUT_CODEDEPLOY_MODE" = "deploy" ]; then
98+
echo -e "$BLUE Deploying to $NO_COLOR$INPUT_CODEDEPLOY_GROUP.";
99+
deployRevision
100+
101+
sleep 10;
102+
pollForActiveDeployments
103+
echo -e "$GREEN Deployed to $NO_COLOR$INPUT_CODEDEPLOY_GROUP!";
104+
else
105+
echo -e "$BLUE Registering deployment to $NO_COLOR$INPUT_CODEDEPLOY_GROUP.";
106+
registerRevision
107+
echo -e "$BLUE Registered deployment to $NO_COLOR$INPUT_CODEDEPLOY_GROUP!";
108+
fi
86109

87-
sleep 10;
88-
pollForActiveDeployments
89-
echo -e "$GREEN Deployed to $NO_COLOR$INPUT_CODEDEPLOY_GROUP!";
90110
exit 0;

0 commit comments

Comments
 (0)