Skip to content

Commit

Permalink
Add logs.
Browse files Browse the repository at this point in the history
  • Loading branch information
everaldorodrigo committed Nov 29, 2023
1 parent 8adfef6 commit 4f21f7f
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 @@ -41,33 +41,34 @@ jobs:
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
id: run_tests
run: |
#!/bin/bash
# Create the ssh key
echo "$AWS_EC2_SSH_KEY" > key.pem # Save the private key to a file
# Save the private key to a file
echo "$AWS_EC2_SSH_KEY" > key.pem
chmod 400 key.pem # Set proper permissions
# 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"
echo "Fetched instances from Auto Scaling Group: $INSTANCE_IDS" >> $GITHUB_OUTPUT
# Extract the instance IDs using jq (JSON processor)
IFS=$'\n' read -d '' -r -a INSTANCES <<< "$(echo "$INSTANCE_IDS" | jq -r '.[]')"
# Iterate over the array
for INSTANCE_ID in "${INSTANCES[@]}"; do
echo "Processing instance: $INSTANCE_ID"
echo "Processing instance: $INSTANCE_ID" >> $GITHUB_OUTPUT
# 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
INSTANCE_IP="${INSTANCE_IP//\"}"
echo "Instance IP: $INSTANCE_IP"
echo "Instance IP: $INSTANCE_IP" >> $GITHUB_OUTPUT
echo "ssh -i key.pem -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ubuntu@$INSTANCE_IP 'cd /home/ubuntu && ./update_mygeneset pull_src'"
echo "ssh -i key.pem -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ubuntu@$INSTANCE_IP 'cd /home/ubuntu && ./update_mygeneset pull_src'" >> $GITHUB_OUTPUT
ssh -i 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 4f21f7f

Please sign in to comment.