Skip to content

Commit adc9c98

Browse files
committed
refactor: separate deployment workflow into distinct frontend and backend jobs and update frontend build command.
1 parent 25445c1 commit adc9c98

1 file changed

Lines changed: 18 additions & 14 deletions

File tree

.github/workflows/server-deploy.yml

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,35 @@ on:
88
- 'client/**'
99

1010
jobs:
11-
deploy:
11+
# ================= FRONTEND =================
12+
frontend:
1213
runs-on: ubuntu-latest
1314

1415
steps:
15-
- name: Checkout code
16-
uses: actions/checkout@v4
16+
- uses: actions/checkout@v4
1717
with:
18-
fetch-depth: 2 # Needed for clean diff logic
18+
fetch-depth: 2
1919

20-
# ---------- FRONTEND BUILD (CI SIDE) ----------
2120
- name: Build frontend
2221
run: |
2322
if git diff --name-only HEAD^ HEAD | grep '^client/' >/dev/null; then
2423
echo "Frontend changed → building"
2524
cd client
25+
2626
echo "VITE_API_URL=${{ secrets.VITE_API_URL }}" > .env.production
2727
echo "VITE_IC_CREDENTIAL=${{ secrets.VITE_IC_CREDENTIAL }}" >> .env.production
2828
echo "VITE_IC_USERNAME=${{ secrets.VITE_IC_USERNAME }}" >> .env.production
2929
echo "VITE_SONG_URL=${{ secrets.VITE_SONG_URL }}" >> .env.production
30-
npm ci
30+
31+
npm install --no-audit --no-fund
3132
npm run build
3233
tar -czf ../client-dist.tar.gz dist
3334
else
3435
echo "Frontend unchanged → skipping"
3536
fi
3637
3738
- name: Upload frontend to VPS
38-
if: success()
39+
if: success() && exists('client-dist.tar.gz')
3940
uses: appleboy/scp-action@v0.1.4
4041
with:
4142
host: ${{ secrets.SERVER_HOST }}
@@ -45,8 +46,16 @@ jobs:
4546
target: /home/ubuntu/
4647
overwrite: true
4748

48-
# ---------- BACKEND DEPLOY (VPS SIDE) ----------
49-
- name: Deploy backend + unpack frontend
49+
# ================= BACKEND =================
50+
backend:
51+
runs-on: ubuntu-latest
52+
53+
steps:
54+
- uses: actions/checkout@v4
55+
with:
56+
fetch-depth: 2
57+
58+
- name: Deploy backend
5059
uses: appleboy/ssh-action@v1.0.3
5160
with:
5261
host: ${{ secrets.SERVER_HOST }}
@@ -57,7 +66,6 @@ jobs:
5766
git fetch origin
5867
git reset --hard origin/main
5968
60-
# Backend
6169
if git diff --name-only HEAD@{1} HEAD | grep '^server/' >/dev/null; then
6270
echo "Backend code changed"
6371
@@ -74,12 +82,8 @@ jobs:
7482
echo "Backend unchanged"
7583
fi
7684
77-
# Frontend
7885
if [ -f /home/ubuntu/client-dist.tar.gz ]; then
79-
echo "Deploying frontend"
8086
sudo rm -rf /var/www/syncvibe-web/*
8187
sudo tar -xzf /home/ubuntu/client-dist.tar.gz -C /var/www/syncvibe-web
8288
rm /home/ubuntu/client-dist.tar.gz
83-
else
84-
echo "Frontend unchanged"
8589
fi

0 commit comments

Comments
 (0)