From fbbaf98e9cf93c8acedabd11b178fc10a39fcfb6 Mon Sep 17 00:00:00 2001 From: everaldorodrigo Date: Wed, 29 Nov 2023 10:08:44 -0800 Subject: [PATCH] Change loop. --- .github/workflows/deploy_prod.yml | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/deploy_prod.yml b/.github/workflows/deploy_prod.yml index dacd04cd..b15e3ea3 100644 --- a/.github/workflows/deploy_prod.yml +++ b/.github/workflows/deploy_prod.yml @@ -28,13 +28,13 @@ jobs: echo "aws_secret_access_key = $AWS_SECRET_ACCESS_KEY" >> ~/.aws/credentials echo "region = $AWS_REGION" >> ~/.aws/credentials - - name: Fetch EC2 instances from Auto Scaling Group - run: | - INSTANCE_IDS=$(aws autoscaling describe-auto-scaling-groups --auto-scaling-group-names $AWS_AUTO_SCALING_GROUP_NAME --query "AutoScalingGroups[0].Instances[*].InstanceId" --output json) - echo "Fetched instances from Auto Scaling Group: $INSTANCE_IDS" + # - name: Fetch EC2 instances from Auto Scaling Group + # run: | + # INSTANCE_IDS=$(aws autoscaling describe-auto-scaling-groups --auto-scaling-group-names $AWS_AUTO_SCALING_GROUP_NAME --query "AutoScalingGroups[0].Instances[*].InstanceId" --output json) + # echo "Fetched instances from Auto Scaling Group: $INSTANCE_IDS" - # INSTANCE_ID_STRING=$(echo $INSTANCE_IDS | jq -r '. | join(" ")') - # echo "Fetched instances from Auto Scaling Group: $INSTANCE_ID_STRING" + # # INSTANCE_ID_STRING=$(echo $INSTANCE_IDS | jq -r '. | join(" ")') + # # echo "Fetched instances from Auto Scaling Group: $INSTANCE_ID_STRING" - name: Open SSH port to GitHub Actions IP run: | @@ -42,6 +42,10 @@ jobs: - name: Deploy to EC2 run: | + # Fetch EC2 instances from Auto Scaling Group + INSTANCE_IDS=$(aws autoscaling describe-auto-scaling-groups --auto-scaling-group-names $AWS_AUTO_SCALING_GROUP_NAME --query "AutoScalingGroups[0].Instances[*].InstanceId" --output json) + echo "Fetched instances from Auto Scaling Group: $INSTANCE_IDS" + # Extract the instance IDs using jq (JSON processor) IFS=$'\n' read -d '' -r -a INSTANCES <<< "$(echo "$INSTANCE_IDS" | jq -r '.[]')"