Skip to content

Commit

Permalink
allow zero desired for deploy-ecs
Browse files Browse the repository at this point in the history
  • Loading branch information
rymarczy committed May 16, 2024
1 parent 4476244 commit b1d3399
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions deploy-ecs/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ inputs:
description: ECS launch type ("FARGATE", "EC2", or "EXTERNAL")
required: false
default: 'FARGATE'
allow-zero-desired:
description: Whether the deploy allows the ECS desiredCount to be 0 (expects "true" or "false"))
required: false
default: 'false'
runs:
using: composite
steps:
Expand All @@ -47,3 +51,4 @@ runs:
DOCKER_TAG: ${{ inputs.docker-tag }}
REQUIRES_SECRETS: ${{ inputs.requires-secrets }}
LAUNCH_TYPE: ${{ inputs.launch-type }}
ALLOW_ZERO_DESIRED: ${{ inputs.allow-zero-desired }}
9 changes: 8 additions & 1 deletion deploy-ecs/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ function check_deployment_complete() {
local deployment_details
local id
local rollout_status
local min_desired_count
local desired_count
local pending_count
local running_count
Expand All @@ -32,8 +33,14 @@ function check_deployment_complete() {
# get rollout state
rollout_status="$(echo "${deployment_details}" | jq -r '.rolloutState // "COMPLETED"')"

# check if 0 desiredCount is allowed
min_desired_count=1
if [ "${ALLOW_ZERO_DESIRED}" = true ]; then
min_desired_count=0
fi

# get current task counts
desired_count="$(echo "${deployment_details}" | jq -r '[.desiredCount, 1] | max')"
desired_count="$(echo "${deployment_details}" | jq -r '[.desiredCount, '"${min_desired_count}"' ] | max')"
pending_count="$(echo "${deployment_details}" | jq -r '.pendingCount')"
running_count="$(echo "${deployment_details}" | jq -r '.runningCount')"
failed_count="$(echo "${deployment_details}" | jq -r '.failedTasks')"
Expand Down

0 comments on commit b1d3399

Please sign in to comment.