1.0.2 #3
Workflow file for this run
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 & Deploy | |
| on: | |
| release: | |
| types: [published] | |
| workflow_dispatch: | |
| env: | |
| REGISTRY: ghcr.io | |
| APP_IMAGE: ghcr.io/${{ github.repository }}/app | |
| FRONTEND_IMAGE: ghcr.io/${{ github.repository }}/frontend | |
| jobs: | |
| # ── Build App (Wippy backend) ──────────────────────────────── | |
| build-app: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build and push app image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: .docker/Dockerfile | |
| push: true | |
| tags: | | |
| ${{ env.APP_IMAGE }}:latest | |
| ${{ env.APP_IMAGE }}:${{ github.event.release.tag_name || github.sha }} | |
| cache-from: type=gha,scope=app | |
| cache-to: type=gha,mode=max,scope=app | |
| # ── Build Frontend (Nuxt SSR) ─────────────────────────────── | |
| build-frontend: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build and push frontend image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: ./frontend | |
| file: ./frontend/.docker/Dockerfile | |
| push: true | |
| tags: | | |
| ${{ env.FRONTEND_IMAGE }}:latest | |
| ${{ env.FRONTEND_IMAGE }}:${{ github.event.release.tag_name || github.sha }} | |
| cache-from: type=gha,scope=frontend | |
| cache-to: type=gha,mode=max,scope=frontend | |
| # ── Deploy to production server ───────────────────────────── | |
| deploy: | |
| runs-on: ubuntu-latest | |
| needs: [build-app, build-frontend] | |
| if: github.event_name == 'release' || github.event_name == 'workflow_dispatch' | |
| steps: | |
| - name: Connect to WireGuard VPN | |
| run: | | |
| sudo apt-get install -y wireguard | |
| echo "${{ secrets.WG_CONFIG }}" | sudo tee /etc/wireguard/wg0.conf > /dev/null | |
| sudo chmod 600 /etc/wireguard/wg0.conf | |
| sudo wg-quick up wg0 | |
| - name: Deploy via SSH | |
| uses: appleboy/ssh-action@v1 | |
| with: | |
| host: ${{ secrets.DEPLOY_HOST }} | |
| port: ${{ secrets.DEPLOY_SSH_PORT || 22 }} | |
| username: ${{ secrets.DEPLOY_USER }} | |
| key: ${{ secrets.DEPLOY_SSH_KEY }} | |
| script: | | |
| cd /servers/buggregator.dev.v2 | |
| git pull origin main | |
| # Pull latest images | |
| docker compose pull app frontend | |
| # Restart app + frontend with new images | |
| docker compose up -d app frontend | |
| # Clean up old images | |
| docker image prune -f |