← back to Open Seo

.github/workflows/ci.yml

80 lines

name: CI

on:
  pull_request:
  push:
    branches:
      - main

concurrency:
  group: ci-${{ github.ref }}
  cancel-in-progress: true

jobs:
  ci:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        uses: actions/checkout@v4
        with:
          ref: ${{ github.event.pull_request.head.sha || github.sha }}

      - name: Setup pnpm
        uses: pnpm/action-setup@v4

      - name: Setup Node.js
        uses: actions/setup-node@v4
        with:
          node-version: 22
          cache: pnpm

      - name: Install dependencies
        run: pnpm install --frozen-lockfile

      - name: Run CI checks
        run: pnpm run ci:check

      - name: Run tests
        run: pnpm run test:ci

      # Runs the leanWorkerBundle generateBundle assertion: fails if a
      # denylisted package (dataforseo-client, autumn-js, ...) re-enters the
      # worker's eager startup graph. See vite-plugin-lean-worker-bundle.ts.
      - name: Build worker (eager-bundle guard)
        run: pnpm vite build
        env:
          NODE_OPTIONS: --max-old-space-size=4096

      - name: Install website dependencies
        run: pnpm --dir web install --frozen-lockfile

      - name: Run website type checks
        run: pnpm --dir web run types:check

      - name: Build website
        run: pnpm --dir web run build

  docker-build:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        uses: actions/checkout@v4
        with:
          ref: ${{ github.event.pull_request.head.sha || github.sha }}

      - name: Set up Buildx
        uses: docker/setup-buildx-action@v3

      - name: Build self-host Docker image
        uses: docker/build-push-action@v6
        with:
          context: .
          file: Dockerfile.selfhost
          push: false
          load: false
          platforms: linux/amd64
          cache-from: type=gha
          cache-to: type=gha,mode=max