feat: dynamically generate player background and glow effects from al… #45
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Syncvibe Platform Deploy | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - 'server/**' | |
| - 'client/**' | |
| workflow_dispatch: | |
| jobs: | |
| # ================= FRONTEND ================= | |
| frontend: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| built: ${{ steps.build.outputs.built }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 2 | |
| - name: Build frontend | |
| id: build | |
| run: | | |
| if git diff --name-only HEAD^ HEAD | grep '^client/' >/dev/null; then | |
| echo "Frontend changed → building" | |
| cd client | |
| echo "VITE_API_URL=${{ secrets.VITE_API_URL }}" > .env.production | |
| echo "VITE_IC_CREDENTIAL=${{ secrets.VITE_IC_CREDENTIAL }}" >> .env.production | |
| echo "VITE_IC_USERNAME=${{ secrets.VITE_IC_USERNAME }}" >> .env.production | |
| echo "VITE_SONG_URL=${{ secrets.VITE_SONG_URL }}" >> .env.production | |
| npm install --no-audit --no-fund | |
| npm run build | |
| tar -czf ../client-dist.tar.gz dist | |
| echo "built=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "Frontend unchanged → skipping" | |
| echo "built=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Upload frontend to VPS | |
| if: steps.build.outputs.built == 'true' | |
| uses: appleboy/scp-action@v0.1.4 | |
| with: | |
| host: ${{ secrets.SERVER_HOST }} | |
| username: ubuntu | |
| key: ${{ secrets.SERVER_SSH_KEY }} | |
| source: client-dist.tar.gz | |
| target: /home/ubuntu/ | |
| overwrite: true | |
| # ================= BACKEND ================= | |
| backend: | |
| runs-on: ubuntu-latest | |
| needs: frontend | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 2 | |
| - name: Deploy backend + frontend | |
| uses: appleboy/ssh-action@v1.0.3 | |
| with: | |
| host: ${{ secrets.SERVER_HOST }} | |
| username: ubuntu | |
| key: ${{ secrets.SERVER_SSH_KEY }} | |
| script: | | |
| set -e | |
| # -------- DEPLOY LOCK -------- | |
| LOCK=/tmp/syncvibe-deploy.lock | |
| exec 9>$LOCK || exit 1 | |
| flock -n 9 || exit 0 | |
| cd /home/ubuntu/syncvibe | |
| git fetch origin | |
| PREV=$(git rev-parse HEAD@{1} || true) | |
| git reset --hard origin/main | |
| # -------- BACKEND DEPLOY -------- | |
| if [ -n "$PREV" ] && git diff --name-only "$PREV" HEAD | grep '^server/' >/dev/null; then | |
| echo "Backend code changed" | |
| if git diff --name-only "$PREV" HEAD | grep '^server/package.json$' >/dev/null; then | |
| cd server | |
| /home/ubuntu/.bun/bin/bun install | |
| cd .. | |
| fi | |
| sudo systemctl daemon-reexec | |
| sudo systemctl restart syncvibe-api.service | |
| sleep 2 | |
| sudo systemctl is-active --quiet syncvibe-api.service | |
| else | |
| echo "Backend unchanged" | |
| fi | |
| # -------- FRONTEND DEPLOY (ATOMIC) -------- | |
| if [ -f /home/ubuntu/client-dist.tar.gz ]; then | |
| echo "Deploying frontend atomically" | |
| TMP_DIR=/var/www/.syncvibe-web-new | |
| sudo rm -rf $TMP_DIR | |
| sudo mkdir -p $TMP_DIR | |
| sudo tar -xzf /home/ubuntu/client-dist.tar.gz -C $TMP_DIR | |
| sudo mv /var/www/syncvibe-web /var/www/syncvibe-web-old || true | |
| sudo mv $TMP_DIR /var/www/syncvibe-web | |
| sudo rm -rf /var/www/syncvibe-web-old | |
| rm /home/ubuntu/client-dist.tar.gz | |
| else | |
| echo "No frontend artifact" | |
| fi |