@@ -53,10 +53,10 @@ Go to your repo → **Settings** → **Secrets and variables** → **Actions**
5353
5454---
5555
56- ## 📦 GitHub Actions Workflow - SSH by Key (` .github/workflows/git-ssh-key.yml ` )
56+ ## 📦 GitHub Actions Workflow - SSH by Key (` .github/workflows/deploy- git-ssh-key.yml ` )
5757
5858``` yaml
59- name : Deploy via SSH
59+ name : Deploy via SSH by Key
6060
6161on :
6262 push :
9090## 📦 GitHub Actions Workflow - SSH by Password (` .github/workflows/git-ssh-password.yml`)
9191
9292` ` ` yaml
93- name: Deploy via SSH
93+ name: Deploy via SSH by Password
9494
9595on:
9696 push:
@@ -102,18 +102,15 @@ jobs:
102102 runs-on: ubuntu-latest
103103
104104 steps:
105- - name: Checkout repo
106- uses: actions/checkout@v4
107-
108- - name: Set up SSH
109- uses: webfactory/ssh-agent@v0.9.0
110- with:
111- ssh-private-key: ${{ secrets.SSH_KEY }}
105+ - name: Install sshpass
106+ run: sudo apt-get update && sudo apt-get install -y sshpass
112107
113- - name: Connect and Deploy
108+ - name: Deploy to Server via SSH
109+ env:
110+ SSHPASS: ${{ secrets.SSH_PASSWORD }}
114111 run: |
115- ssh -o StrictHostKeyChecking=no ${{ secrets.SSH_USERNAME }}@${{ secrets.SSH_HOST }} << ' EOF'
116- cd ${{ secrets.PROJECT_PATH }}
112+ sshpass -e ssh -p ${{ secrets.SSH_PORT }} - o StrictHostKeyChecking=no ${{ secrets.SSH_USERNAME }}@${{ secrets.SSH_HOST }} << EOF
113+ cd ${{ secrets.PROJECT_DIRECTORY }}
117114 git fetch origin main
118115 git reset --hard origin/main
119116 git clean -fd
@@ -126,7 +123,7 @@ jobs:
126123- Fork this repo (or copy deploy.yml to your own)
127124- Add the required GitHub secrets
128125- Ensure SSH access from GitHub to your remote server
129- - Push to main branch – the deployment runs automatically!
126+ - Push to main branch - the deployment runs automatically!
130127
131128# # 🛠️ Customization
132129
0 commit comments