Skip to content

Commit 5493ff6

Browse files
committed
Add SSH connection test before deploy
1 parent b6914e6 commit 5493ff6

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

.github/workflows/deploy.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,17 @@ jobs:
2222
cat << 'EOF' > ~/.ssh/id_rsa
2323
${{ secrets.EC2_SSH_KEY }}
2424
EOF
25-
chmod 600 ~/.ssh/id_rsa
25+
chmod 600 ~/.ssh/id_rsa
2626
2727
- name: Add EC2 to known_hosts
2828
run: |
2929
mkdir -p ~/.ssh
3030
ssh-keyscan -H ${{ secrets.EC2_HOST }} >> ~/.ssh/known_hosts
3131
32+
- name: Test EC2 SSH connection
33+
run: |
34+
ssh -i ~/.ssh/id_rsa -o StrictHostKeyChecking=no ${{ secrets.EC2_USER }}@${{ secrets.EC2_HOST }} "echo Connection successful"
35+
3236
- name: Deploy Backend
3337
run: |
3438
ssh -i ~/.ssh/id_rsa ${{ secrets.EC2_USER }}@${{ secrets.EC2_HOST }} "

0 commit comments

Comments
 (0)