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 Test | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| cache: "npm" | |
| - name: Enable Corepack | |
| run: corepack enable | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Install Turbo globally | |
| run: npm install -g turbo | |
| - name: Generate Prisma types | |
| run: npm run generate | |
| - name: Build workspace packages first | |
| run: npm run build | |
| - name: Run type checking | |
| run: npm run check-types | |
| - name: Run linting | |
| run: npm run lint | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to Container Registry | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push sidecar image | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: apps/sidecar/Dockerfile | |
| push: true | |
| tags: | | |
| ghcr.io/${{ github.repository }}/shadow-sidecar:latest | |
| ghcr.io/${{ github.repository }}/shadow-sidecar:${{ github.sha }} | |
| platforms: linux/amd64 | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Upload build artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: build-artifacts-${{ github.sha }} | |
| path: | | |
| apps/*/dist/ | |
| packages/*/dist/ | |
| packages/db/generated/ | |
| retention-days: 7 | |
| if-no-files-found: warn |