@@ -53,10 +53,10 @@ Go to your repo → **Settings** → **Secrets and variables** → **Actions**
53
53
54
54
---
55
55
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 ` )
57
57
58
58
``` yaml
59
- name : Deploy via SSH
59
+ name : Deploy via SSH by Key
60
60
61
61
on :
62
62
push :
90
90
## 📦 GitHub Actions Workflow - SSH by Password (` .github/workflows/git-ssh-password.yml`)
91
91
92
92
` ` ` yaml
93
- name: Deploy via SSH
93
+ name: Deploy via SSH by Password
94
94
95
95
on:
96
96
push:
@@ -102,18 +102,15 @@ jobs:
102
102
runs-on: ubuntu-latest
103
103
104
104
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
112
107
113
- - name: Connect and Deploy
108
+ - name: Deploy to Server via SSH
109
+ env:
110
+ SSHPASS: ${{ secrets.SSH_PASSWORD }}
114
111
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 }}
117
114
git fetch origin main
118
115
git reset --hard origin/main
119
116
git clean -fd
@@ -126,7 +123,7 @@ jobs:
126
123
- Fork this repo (or copy deploy.yml to your own)
127
124
- Add the required GitHub secrets
128
125
- 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!
130
127
131
128
# # 🛠️ Customization
132
129
0 commit comments