Skip to content

Commit d95b220

Browse files
authored
add loop for wait
1 parent b155512 commit d95b220

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

.github/workflows/deploy.yml

+12-3
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,20 @@ jobs:
4040
with:
4141
aws-region: ${{ vars.AWS_REGION }}
4242
role-to-assume: arn:aws:iam::${{ secrets[format('{0}_ACCOUNT_ID', env.ACCOUNT)] }}:role/delegatedadmin/developer/ab2d-${{ env.ACCOUNT }}-github-actions
43+
4344
- name: Deploy ECS service to run on latest image in ECR
4445
env:
4546
SERVICE_NAME: ab2d-${{ vars[format('{0}_DEPLOYMENT_ENV', inputs.environment)] }}-${{ inputs.module }}
4647
run: |
47-
echo "Deploying service $SERVICE_NAME"
48+
echo "Deploying ECS service: $SERVICE_NAME"
4849
aws ecs update-service --cluster "$SERVICE_NAME" --service "$SERVICE_NAME" --force-new-deployment > /dev/null
49-
aws ecs wait services-stable --cluster "$SERVICE_NAME" --services "$SERVICE_NAME" --max-attempts 15
50-
50+
echo "Waiting for new task to start..."
51+
sleep 10
52+
TASK_ARN=$(aws ecs list-tasks --cluster "$SERVICE_NAME" --service-name "$SERVICE_NAME" --desired-status RUNNING --query 'taskArns[-1]' --output text)
53+
echo "New task: $TASK_ARN"
54+
exit_status="1"
55+
while [ "${exit_status}" != "0" ]; do
56+
echo "Waiting for task to stop..."
57+
aws ecs wait tasks-stopped --cluster "$SERVICE_NAME" --tasks "$TASK_ARN"
58+
exit_status="$?"
59+
done

0 commit comments

Comments
 (0)