Skip to content

Commit cb85ad5

Browse files
authored
Merge pull request #3 from sourcetoad/colors
Colors
2 parents d1592b8 + 6892319 commit cb85ad5

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

action.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ inputs:
3333
codedeploy_group:
3434
description: 'AWS CodeDeploy Application Group'
3535
required: true
36+
max_polling_iterations:
37+
description: 'Max amount of iterations (15s increments) to wait for a deployment'
38+
required: false
39+
default: '60'
3640
runs:
3741
using: 'docker'
3842
image: 'Dockerfile'

deploy.sh

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
#!/bin/bash -l
22
set -e
3-
MAX_POLLING_ITERATIONS=60
3+
4+
NO_COLOR='\033[0m'
5+
RED='\033[0;31m'
6+
GREEN='\033[0;32m'
7+
ORANGE='\033[0;33m'
8+
BLUE='\033[0;34m'
49

510
# 1) Load our permissions in for aws-cli
611
export AWS_ACCESS_KEY_ID=$INPUT_AWS_ACCESS_KEY
@@ -30,7 +35,8 @@ fi
3035

3136
# 3) Upload the deployment to S3, drop old archive.
3237
function getArchiveETag() {
33-
aws s3api head-object --bucket "$INPUT_S3_BUCKET" \
38+
aws s3api head-object \
39+
--bucket "$INPUT_S3_BUCKET" \
3440
--key "$INPUT_S3_FOLDER"/"$ZIP_FILENAME" \
3541
--query ETag --output text
3642
}
@@ -42,18 +48,19 @@ rm "$ZIP_FILENAME"
4248

4349
# 4) Start the CodeDeploy
4450
function getActiveDeployments() {
45-
aws deploy list-deployments --application-name "$INPUT_CODEDEPLOY_NAME" \
51+
aws deploy list-deployments \
52+
--application-name "$INPUT_CODEDEPLOY_NAME" \
4653
--deployment-group-name "$INPUT_CODEDEPLOY_GROUP" \
4754
--include-only-statuses "Queued" "InProgress" "Stopped" | jq -r '.deployments';
4855
}
4956

5057
function pollForActiveDeployments() {
5158
deadlockCounter=0;
5259
while [ "$(getActiveDeployments)" != "[]" ]; do
53-
echo "::warning::Deployment in progress. Sleeping 15 seconds. (Try $((++deadlockCounter)))";
60+
echo -e "$ORANGE Deployment in progress. Sleeping 15 seconds. (Try $((++deadlockCounter)))";
5461

55-
if [ "$deadlockCounter" -gt "$MAX_POLLING_ITERATIONS" ]; then
56-
echo "::error:: Max polling iterations reached (15min)."
62+
if [ "$deadlockCounter" -gt "$INPUT_MAX_POLLING_ITERATIONS" ]; then
63+
echo -e "$RED Max polling iterations reached (max_polling_iterations)."
5764
exit 1;
5865
fi
5966
sleep 15s;
@@ -70,10 +77,10 @@ function deployRevision() {
7077
--s3-location bucket="$INPUT_S3_BUCKET",bundleType=zip,eTag="$ZIP_ETAG",key="$INPUT_S3_FOLDER"/"$ZIP_FILENAME" > /dev/null 2>&1
7178
}
7279

73-
echo "Deploying to $INPUT_CODEDEPLOY_GROUP.";
80+
echo -e "$BLUE Deploying to $NO_COLOR$INPUT_CODEDEPLOY_GROUP.";
7481
deployRevision
7582

7683
sleep 10;
7784
pollForActiveDeployments
78-
echo "Deployed to $INPUT_CODEDEPLOY_GROUP!";
85+
echo -e "$GREEN Deployed to $NO_COLOR$INPUT_CODEDEPLOY_GROUP!";
7986
exit 0;

0 commit comments

Comments
 (0)