Skip to content

Commit

Permalink
ec_user replaced with secret variable in deploy.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
anuj0456 committed Jan 12, 2025
1 parent 8e90685 commit 8363328
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ jobs:
# Debug information
echo "Testing SSH connection..."
ssh -i ~/.ssh/id_rsa -o BatchMode=yes -o StrictHostKeyChecking=no -o ConnectTimeout=5 ec2-user@${{ secrets.EC2_HOST }} 'echo SSH connection successful'
ssh -i ~/.ssh/id_rsa -o BatchMode=yes -o StrictHostKeyChecking=no -o ConnectTimeout=5 ${{ secrets.EC2_USER }}@${{ secrets.EC2_HOST }} 'echo SSH connection successful'
cat >>~/.ssh/config <<END
Host ${{ secrets.EC2_HOST }}
HostName ${{ secrets.EC2_HOST }}
User ec2-user
User ${{ secrets.EC2_USER }}
IdentityFile ~/.ssh/id_rsa
StrictHostKeyChecking no
UserKnownHostsFile ~/.ssh/known_hosts
Expand All @@ -65,7 +65,7 @@ jobs:
-czf deploy.tar.gz .
echo "Copying files to EC2..."
scp deploy.tar.gz ec2-user@${{ secrets.EC2_HOST }}:~/
scp deploy.tar.gz ${{ secrets.EC2_USER }}@${{ secrets.EC2_HOST }}:~/
# Create deploy script
echo '#!/bin/bash
Expand Down Expand Up @@ -106,7 +106,7 @@ jobs:
run: |
# Debug SSH connection
echo "Testing connection before deployment..."
if ! ssh ec2-user@${{ secrets.EC2_HOST }} 'echo "Connection test successful"'; then
if ! ssh ${{ secrets.EC2_USER }}@${{ secrets.EC2_HOST }} 'echo "Connection test successful"'; then
echo "Failed to connect to EC2 instance"
exit 1
fi
Expand Down Expand Up @@ -160,8 +160,8 @@ jobs:
EOL
chmod +x deploy.sh
scp deploy.sh ec2-user@${{ secrets.EC2_HOST }}:~/deploy.sh
ssh ec2-user@${{ secrets.EC2_HOST }} "./deploy.sh"
scp deploy.sh ${{ secrets.EC2_USER }}@${{ secrets.EC2_HOST }}:~/deploy.sh
ssh ${{ secrets.EC2_USER }}@${{ secrets.EC2_HOST }} "./deploy.sh"
- name: Cleanup
if: always()
Expand Down

0 comments on commit 8363328

Please sign in to comment.