attempt to fix issue where changes to build are not reflected on server #27
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: Build 🏗️ and Deploy 🚀 to VPS | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - main | |
| release: | |
| types: [published] | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| name: Build | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22.x | |
| cache: "npm" | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build distribution | |
| run: npm run build --if-present | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: app-build | |
| path: .output/ | |
| include-hidden-files: true | |
| deploy: | |
| runs-on: ubuntu-latest | |
| name: Deploy to VPS | |
| needs: build | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download build artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: app-build | |
| path: ./.output | |
| - name: Deploy to VPS | |
| uses: appleboy/scp-action@v1 | |
| with: | |
| host: ${{ secrets.SSH_HOST }} | |
| username: ${{ secrets.SSH_USERNAME }} | |
| key: ${{ secrets.SSH_KEY }} | |
| port: ${{ secrets.SSH_PORT }} | |
| passphrase: ${{ secrets.SSH_PASSPHRASE }} | |
| source: "./.output,./src,./public,./mdx,./nginx,./package.json,./package-lock.json,./vite.config.ts,./tsconfig.json,./docker-compose.yml,./Dockerfile" | |
| target: "~/sourcedepth.com/" | |
| overwrite: true | |
| rm: true | |
| - name: Build and restart Docker containers | |
| uses: appleboy/ssh-action@v1 | |
| with: | |
| host: ${{ secrets.SSH_HOST }} | |
| username: ${{ secrets.SSH_USERNAME }} | |
| key: ${{ secrets.SSH_KEY }} | |
| port: ${{ secrets.SSH_PORT }} | |
| passphrase: ${{ secrets.SSH_PASSPHRASE }} | |
| script: | | |
| cd ~/sourcedepth.com | |
| docker compose down | |
| docker compose build --pull --no-cache | |
| docker compose up -d | |
| docker system prune -f |