Skip to content

Commit ae346a7

Browse files
authored
Update docker-image.yml
1 parent 94b9b94 commit ae346a7

File tree

1 file changed

+3
-23
lines changed

1 file changed

+3
-23
lines changed

.github/workflows/docker-image.yml

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -26,29 +26,9 @@ jobs:
2626
id: push-docker-image
2727
run: docker push ${{secrets.DOCKER_USERNAME}}/webportfolio:latest
2828

29-
- name: Set up SSH key
30-
run: |
31-
mkdir -p ~/.ssh
32-
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
33-
chmod 600 ~/.ssh/id_rsa
34-
35-
# Ensure VPS_HOSTNAME is set correctly
36-
echo "Checking VPS_HOSTNAME: $VPS_HOSTNAME"
37-
38-
# Add the server to known hosts using ssh-keyscan
39-
ssh-keyscan -H $VPS_HOSTNAME >> ~/.ssh/known_hosts
40-
41-
# Start the SSH agent and add the private key
42-
eval $(ssh-agent -s)
43-
echo "$SSH_PRIVATE_KEY" | ssh-add -
44-
45-
env:
46-
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
47-
VPS_HOSTNAME: ${{ secrets.VPS_HOSTNAME }} # Make sure you have this secret
29+
- name: Install sshpass
30+
run: sudo apt-get install sshpass
4831

4932
- name: Connect to server via SSH
5033
run: |
51-
ssh -i ~/.ssh/id_rsa -o StrictHostKeyChecking=no -o GSSAPIAuthentication=no username@$VPS_HOSTNAME "echo 'Connected successfully!'"
52-
env:
53-
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
54-
VPS_HOSTNAME: ${{ secrets.VPS_HOSTNAME }}
34+
sshpass -p ${{secrets.VPS_PASSWORD}} ssh -o StrictHostKeyChecking=no ${{secrets.VPS_USERNAME}}@${{secrets.VPS_HOST}} "your deployment commands here"

0 commit comments

Comments
 (0)