Deploy on Server #32
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 on Server | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| build-frontend: | |
| name: Frontend Build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 8 | |
| - name: Cache pnpm store | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.pnpm-store | |
| key: ${{ runner.os }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }} | |
| - run: pnpm install | |
| - name: Build Frontend | |
| env: | |
| VITE_API_URL: ${{ secrets.VITE_API_URL }} | |
| run: pnpm --filter client run build | |
| - name: Upload client/dist | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: client-dist | |
| path: client/dist | |
| build-backend: | |
| name: Backend Build | |
| runs-on: [self-hosted, boost-was] | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| - name: Build Backend Image | |
| env: | |
| NODE_ENV: production | |
| MONGO_URI: ${{ secrets.MONGO_URI }} | |
| JWT_SECRET: ${{ secrets.JWT_SECRET }} | |
| JWT_REFRESH_SECRET: ${{ secrets.JWT_REFRESH_SECRET }} | |
| AI_PROMPT: ${{ secrets.AI_PROMPT }} | |
| AI_API_URL: ${{ secrets.AI_API_URL }} | |
| AI_API_KEY: ${{ secrets.AI_API_KEY }} | |
| run: docker-compose up -d --build backend | |
| deploy: | |
| name: Deploy on Server | |
| needs: [build-frontend, build-backend] | |
| runs-on: [self-hosted, boost-was] | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| - name: Clean client/dist | |
| run: rm -rf client/dist | |
| - name: Download client-dist | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: client-dist | |
| path: client/dist | |
| - name: Reload Nginx | |
| env: | |
| NODE_ENV: production | |
| MONGO_URI: ${{ secrets.MONGO_URI }} | |
| JWT_SECRET: ${{ secrets.JWT_SECRET }} | |
| JWT_REFRESH_SECRET: ${{ secrets.JWT_REFRESH_SECRET }} | |
| VITE_API_URL: ${{ secrets.VITE_API_URL }} | |
| AI_PROMPT: ${{ secrets.AI_PROMPT }} | |
| AI_API_URL: ${{ secrets.AI_API_URL }} | |
| AI_API_KEY: ${{ secrets.AI_API_KEY }} | |
| run: docker-compose up -d --no-build --force-recreate nginx | |
| - name: Cleanup | |
| run: docker image prune -f |