Skip to content

Commit

Permalink
Change loop.
Browse files Browse the repository at this point in the history
  • Loading branch information
everaldorodrigo committed Nov 29, 2023
1 parent 5f9af8f commit fbbaf98
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions .github/workflows/deploy_prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,24 @@ 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: |
aws ec2 authorize-security-group-ingress --group-id $AWS_SECURITY_GROUP_ID --protocol tcp --port 22 --cidr $(curl -s https://api.ipify.org)/32
- 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 '.[]')"
Expand Down

0 comments on commit fbbaf98

Please sign in to comment.