fix(deploy): discard local server changes before git pull #20
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: Deploy to Self-Hosted Server | |
| on: | |
| push: | |
| branches: [main, master] | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| name: Build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: latest | |
| - name: Install dependencies | |
| run: bun install | |
| - name: Build | |
| run: bun run build | |
| env: | |
| VITE_SUPABASE_URL: ${{ secrets.VITE_SUPABASE_URL }} | |
| VITE_SUPABASE_PUBLISHABLE_KEY: ${{ secrets.VITE_SUPABASE_PUBLISHABLE_KEY }} | |
| VITE_SUPABASE_PROJECT_ID: ${{ secrets.VITE_SUPABASE_PROJECT_ID }} | |
| - name: Upload dist artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: dist | |
| path: dist/ | |
| retention-days: 1 | |
| deploy: | |
| name: Deploy to webftp.ssmg4.dpdns.org | |
| needs: build | |
| runs-on: self-hosted | |
| steps: | |
| - name: Download dist artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: dist | |
| path: dist/ | |
| - name: Deploy frontend to web root | |
| run: | | |
| rsync -a --delete dist/ ${{ secrets.DEPLOY_PATH }}/ | |
| - name: Update server code | |
| run: | | |
| cd /var/www/webftp | |
| git fetch origin | |
| git checkout -- . | |
| git pull --ff-only | |
| - name: Install server dependencies | |
| run: | | |
| cd /var/www/webftp/server | |
| npm ci --omit=dev | |
| - name: Restart proxy server | |
| run: | | |
| pm2 restart webftp-proxy |