Skip to content

Commit

Permalink
Check for deployments in progress
Browse files Browse the repository at this point in the history
* The `create-codebuild-deployment.sh` script fails to create a new
  Deployment, if there is already one in progress.
* This adds in a check loop, and waits until any current Deployments are
  complete before attempting to create a new one.
  • Loading branch information
Stretch96 committed Jun 28, 2024
1 parent fb2fcb5 commit 59536ba
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions local-exec-scripts/create-codedeploy-deployment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,25 @@ DEPLOYMENT_REVISION=$(
}'
)

echo "==> Checking current Deployments for '$APPLICATION_NAME' ..."
CURRENT_DEPLOYMENT="deployment_check"
while [ "$CURRENT_DEPLOYMENT" != "None" ]
do
CURRENT_DEPLOYMENT=$(aws deploy list-deployments \
--application-name "$APPLICATION_NAME" \
--deployment-group-name "$GROUP_NAME" \
--include-only-statuses Created InProgress Queued \
--output text \
--query '[deploymentId]' \
| head -n1
)
if [ "$CURRENT_DEPLOYMENT" != "None" ]
then
echo "There is a current deployment In Progress or Queued ($CURRENT_DEPLOYMENT). Waiting before creating a new one ..."
sleep 10
fi
done

echo "==> Creating Deployment for '$APPLICATION_NAME' ..."
DEPLOYMENT_ID=$(
aws deploy create-deployment \
Expand All @@ -73,7 +92,7 @@ DEPLOYMENT_ID=$(
echo "==> Checking deployment '$DEPLOYMENT_ID' ..."
DEPLOYMENT_STATUS=$(
aws deploy get-deployment \
--deployment-id $DEPLOYMENT_ID \
--deployment-id "$DEPLOYMENT_ID" \
--output text \
--query '[deploymentInfo.status]'
)
Expand All @@ -89,7 +108,7 @@ do
echo "==> Deployment status: $DEPLOYMENT_STATUS..."
DEPLOYMENT_STATUS=$(
aws deploy get-deployment \
--deployment-id $DEPLOYMENT_ID \
--deployment-id "$DEPLOYMENT_ID" \
--output text \
--query '[deploymentInfo.status]'
)
Expand Down

0 comments on commit 59536ba

Please sign in to comment.