Skip to content

Commit 5935629

Browse files
authored
Update main.yml
1 parent 1fdc91a commit 5935629

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

.github/workflows/main.yml

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ jobs:
1313
- name: Checkout Repository
1414
uses: actions/checkout@v3
1515

16-
- name: Install expect
16+
- name: Install SSH Agent and Tools
1717
run: |
1818
sudo apt-get update
19-
sudo apt-get install -y expect
19+
sudo apt-get install -y openssh-client
2020
2121
- name: Set up SSH with passphrase
2222
env:
@@ -27,25 +27,16 @@ jobs:
2727
echo "$SSH_PRIVATE_KEY" > ~/.ssh/deployment_key
2828
chmod 600 ~/.ssh/deployment_key
2929
eval "$(ssh-agent -s)"
30-
# Clear the agent to ensure no other keys are used
31-
ssh-add -D
32-
# Add only the correct key to the agent
33-
ssh-add ~/.ssh/deployment_key
34-
# Use expect to send the passphrase for the key
35-
expect -c "
36-
spawn ssh-add ~/.ssh/deployment_key
37-
expect \"Enter passphrase for ~/.ssh/deployment_key:\"
38-
send \"$VM_PASSPHRASE\r\"
39-
interact
40-
"
30+
# Add the private key to the agent and provide the passphrase non-interactively
31+
echo "$VM_PASSPHRASE" | ssh-add ~/.ssh/deployment_key
4132
4233
- name: Add VM to known_hosts
4334
run: |
4435
ssh-keyscan -H ${{ secrets.VM_HOST }} >> ~/.ssh/known_hosts
4536
4637
- name: Synchronize Code with VM Using rsync
4738
env:
48-
RSYNC_RSH: "ssh -i ~/.ssh/deployment_key -o IdentitiesOnly=yes" # Explicitly specify the SSH key and disable other key attempts
39+
RSYNC_RSH: "ssh -i ~/.ssh/deployment_key -o IdentitiesOnly=yes" # Explicitly specify the SSH key for rsync
4940
run: |
5041
rsync -avz --checksum --exclude='.git' ./ ${{ secrets.VM_USER }}@${{ secrets.VM_HOST }}:/home/dev/
5142

0 commit comments

Comments
 (0)