Skip to content

Commit

Permalink
Clean code.
Browse files Browse the repository at this point in the history
  • Loading branch information
everaldorodrigo committed Nov 29, 2023
1 parent 08ea5e7 commit 1676fc1
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions .github/workflows/deploy_prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,25 +37,26 @@ jobs:
- name: Deploy to EC2
run: |
echo "LOG: Creating key"
echo "$AWS_EC2_SSH_KEY" > ~/.aws/key.pem
chmod 400 ~/.aws/key.pem # Set proper permissions
# Fetch EC2 instances from Auto Scaling Group
echo "LOG: 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 text)
# Create array with list of instances
echo "LOG: Create array with list of instances"
INSTANCES=( $INSTANCE_IDS )
# Iterate over the array
echo "LOG: Iterate over the instances"
for INSTANCE_ID in "${INSTANCES[@]}"
do
# Get instance IP
echo "LOG: Get instance IP"
INSTANCE_IP=$(aws ec2 describe-instances --instance-ids $INSTANCE_ID --query "Reservations[0].Instances[0].PublicIpAddress" --output json)
# Remove double quotes from INSTANCE_IP
echo "LOG: Remove double quotes from INSTANCE_IP"
INSTANCE_IP="${INSTANCE_IP//\"}"
echo "ssh -i ~/.aws/key.pem -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ubuntu@$INSTANCE_IP 'cd /home/ubuntu && ./update_mygeneset pull_src'"
echo "LOG: Running update script in the remote instance"
ssh -i ~/.aws/key.pem -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ubuntu@$INSTANCE_IP 'cd /home/ubuntu && ./update_mygeneset pull_src'
done
Expand Down

0 comments on commit 1676fc1

Please sign in to comment.