@@ -12,12 +12,16 @@ jobs:
1212 frontend :
1313 runs-on : ubuntu-latest
1414
15+ outputs :
16+ built : ${{ steps.build.outputs.built }}
17+
1518 steps :
1619 - uses : actions/checkout@v4
1720 with :
1821 fetch-depth : 2
1922
2023 - name : Build frontend
24+ id : build
2125 run : |
2226 if git diff --name-only HEAD^ HEAD | grep '^client/' >/dev/null; then
2327 echo "Frontend changed → building"
@@ -31,12 +35,14 @@ jobs:
3135 npm install --no-audit --no-fund
3236 npm run build
3337 tar -czf ../client-dist.tar.gz dist
38+ echo "built=true" >> $GITHUB_OUTPUT
3439 else
3540 echo "Frontend unchanged → skipping"
41+ echo "built=false" >> $GITHUB_OUTPUT
3642 fi
3743
3844 - name : Upload frontend to VPS
39- if : success() && exists('client-dist.tar.gz')
45+ if : steps.build.outputs.built == 'true'
4046 uses : appleboy/scp-action@v0.1.4
4147 with :
4248 host : ${{ secrets.SERVER_HOST }}
@@ -49,13 +55,14 @@ jobs:
4955 # ================= BACKEND =================
5056 backend :
5157 runs-on : ubuntu-latest
58+ needs : frontend
5259
5360 steps :
5461 - uses : actions/checkout@v4
5562 with :
5663 fetch-depth : 2
5764
58- - name : Deploy backend
65+ - name : Deploy backend + frontend
5966 uses : appleboy/ssh-action@v1.0.3
6067 with :
6168 host : ${{ secrets.SERVER_HOST }}
7077 echo "Backend code changed"
7178
7279 if git diff --name-only HEAD@{1} HEAD | grep '^server/package.json$' >/dev/null; then
73- echo "Dependencies changed → bun install"
7480 cd server
7581 /home/ubuntu/.bun/bin/bun install
7682 cd ..
8389 fi
8490
8591 if [ -f /home/ubuntu/client-dist.tar.gz ]; then
92+ echo "Deploying frontend"
8693 sudo rm -rf /var/www/syncvibe-web/*
8794 sudo tar -xzf /home/ubuntu/client-dist.tar.gz -C /var/www/syncvibe-web
8895 rm /home/ubuntu/client-dist.tar.gz
96+ else
97+ echo "No frontend artifact"
8998 fi
0 commit comments