File tree Expand file tree Collapse file tree 1 file changed +3
-23
lines changed
Expand file tree Collapse file tree 1 file changed +3
-23
lines changed Original file line number Diff line number Diff line change 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"
You can’t perform that action at this time.
0 commit comments