Skip to content

Commit

Permalink
ci: recovered the deploy-service.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
CMCDragonkai committed Oct 17, 2023
1 parent 41273c6 commit 138fcdf
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions scripts/deploy-service.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env bash

set -o errexit # abort on nonzero exitstatus
set -o nounset # abort on unbound variable
set -o pipefail # don't hide errors within pipes

required_env_vars=(
AWS_DEFAULT_REGION
AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
)

for var in "${required_env_vars[@]}"; do
if [ -z ${!var+x} ]; then
printf '%s\n' "Unset $var environment variable" >&2
exit 1
fi
done

cluster="$1"

if [ -z "$cluster" ]; then
printf '%s\n' 'Unset or empty ECS cluster name' >&2
exit 1
fi

services=$(aws ecs list-services --cluster polykey-testnet --output json | jq -r '.serviceArns[] | capture("(?<service>polykey-testnet-[a-zA-Z0-9]+)$") | .service' )

for service in $services; do
echo updating service "$service"
aws ecs update-service \
--cluster "$cluster" \
--service "$service" \
--force-new-deployment \
--output json \
--query 'service.{
serviceName: serviceName,
serviceArn: serviceArn,
status: status, deployments: deployments[].{
id: id,
status: status,
rolloutState: rolloutState,
rolloutStateReason: rolloutStateReason
}
}'
done

0 comments on commit 138fcdf

Please sign in to comment.