Skip to content

Commit d8519ef

Browse files
author
MuhammadTahaNasir
committed
🚀 Make deploy-to-VPS workflow template-safe
1 parent b9f166d commit d8519ef

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

.github/workflows/vps-deploy.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,19 @@ on:
77
jobs:
88
deploy:
99
runs-on: ubuntu-latest
10+
if: ${{ secrets.VPS_KEY != '' && secrets.VPS_IP != '' && secrets.VPS_USER != '' }}
1011
steps:
1112
- uses: actions/checkout@v4
13+
1214
- name: Set up SSH
1315
run: |
1416
mkdir -p ~/.ssh
1517
echo "${{ secrets.VPS_KEY }}" > ~/.ssh/id_rsa
1618
chmod 600 ~/.ssh/id_rsa
17-
ssh-keyscan -H your.vps.ip >> ~/.ssh/known_hosts
19+
ssh-keyscan -H ${{ secrets.VPS_IP }} >> ~/.ssh/known_hosts
1820
1921
- name: Rsync to VPS
20-
run: rsync -avz --exclude=".git" ./ youruser@your.vps.ip:/var/www/your-app
22+
run: rsync -avz --exclude=".git" ./ ${{ secrets.VPS_USER }}@${{ secrets.VPS_IP }}:/var/www/your-app
2123

2224
- name: Restart App on VPS
23-
run: ssh youruser@your.vps.ip 'cd /var/www/your-app && docker-compose up -d --build'
25+
run: ssh ${{ secrets.VPS_USER }}@${{ secrets.VPS_IP }} 'cd /var/www/your-app && docker-compose up -d --build'

0 commit comments

Comments
 (0)