> ## Documentation Index
> Fetch the complete documentation index at: https://docs.folksbase.joselito.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# CI/CD

> GitHub Actions workflows that run on every pull request and push to main.

folksbase uses GitHub Actions for continuous integration and selective deployment. Workflows live in `.github/workflows/`.

## CI Pipeline (`ci.yml`)

Runs on every pull request targeting `main`. All jobs must pass before merging.

```mermaid theme={"dark"}
graph LR
    A[PR Opened] --> B[Lint]
    A --> C[Typecheck]
    A --> D[Test]
    B --> E[Build]
    C --> E
    D --> E
    A --> F[Claude Code Review]
```

### Jobs

| Job                | Command          | What It Checks                                                    |
| ------------------ | ---------------- | ----------------------------------------------------------------- |
| Lint               | `pnpm lint`      | Biome formatting and lint rules                                   |
| Typecheck          | `pnpm typecheck` | TypeScript strict mode across all packages                        |
| Test               | `pnpm test`      | Vitest unit tests across all packages                             |
| Build              | `pnpm build`     | Full production build (runs after lint, typecheck, and test pass) |
| Claude Code Review | —                | AI-powered review against AGENTS.md rules                         |

The first three jobs (lint, typecheck, test) run in parallel. The build job only runs after all three succeed, catching integration issues early without wasting CI minutes.

### Claude Code Review

An AI reviewer checks every PR against the project rules in AGENTS.md. It looks for:

* TypeScript violations (`any`, non-null assertions, missing types)
* Backend layer violations (routes importing from `@folksbase/db`)
* `console.log` usage (should use the structured logger)
* `process.env` usage (should use the typed `env` module)
* OFFSET-based pagination (should use cursor-based)
* Redis calls without TTL
* Inngest jobs without `step.run()` wrappers

This runs as a separate job and posts inline comments on the PR.

### Concurrency

```yaml theme={"dark"}
concurrency:
  group: ci-${{ github.ref }}
  cancel-in-progress: true
```

If you push again while CI is running, the previous run is cancelled. This saves CI minutes on rapid iteration.

## Storybook Deployment (`deploy-storybook.yml`)

Deploys the Storybook component documentation to Netlify. Only triggers when relevant files change.

### Trigger Paths

```yaml theme={"dark"}
paths:
  - "apps/web/src/components/**"
  - "apps/web/.storybook/**"
  - "packages/types/**"
```

Changes to components, Storybook config, or shared types trigger a rebuild. Other changes (API, docs, etc.) are ignored.

### Process

1. Installs dependencies with `pnpm install`
2. Builds Storybook with `pnpm --filter @folksbase/web build-storybook`
3. Deploys the static output to Netlify

Requires `NETLIFY_AUTH_TOKEN` and `NETLIFY_SITE_ID` secrets in the repository settings.

## Platform Auto-Deploys

These aren't GitHub Actions — they're platform-native deploy hooks:

| Platform | Trigger        | What Deploys                                |
| -------- | -------------- | ------------------------------------------- |
| Vercel   | Push to `main` | Web app (`apps/web`)                        |
| Render   | Push to `main` | API (`apps/api`)                            |
| Mintlify | Push to `main` | Docs (`apps/docs`) — auto-syncs with GitHub |

## Local Equivalents

The CI pipeline mirrors the local git hooks:

| CI Job    | Local Hook   | Command          |
| --------- | ------------ | ---------------- |
| Lint      | `pre-commit` | `pnpm lint`      |
| Typecheck | `pre-push`   | `pnpm typecheck` |
| Test      | `pre-push`   | `pnpm test`      |
| Build     | `pre-push`   | `pnpm build`     |

If your code passes the local hooks, it should pass CI. The hooks are configured in `.githooks/` and activated automatically by `pnpm install`.

## Required Secrets

| Secret               | Used By                     |
| -------------------- | --------------------------- |
| `ANTHROPIC_API_KEY`  | Claude code review workflow |
| `NETLIFY_AUTH_TOKEN` | Storybook deployment        |
| `NETLIFY_SITE_ID`    | Storybook deployment        |

Add these in your GitHub repository under **Settings → Secrets and variables → Actions**.
