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

# CI/CD Setup

> Automate translations in your deployment pipeline

Run LazyLocales translations automatically as part of your CI/CD pipeline. This ensures translations are always up to date before deployment.

## Prerequisites

1. A LazyLocales project with a `lazylocales.config.json` committed to your repo
2. A **read\_write** API token (generated in your project settings)

## Generate an API token

<Steps>
  <Step title="Go to your project settings">
    Open your project at [lazylocales.com](https://lazylocales.com) and navigate to Settings.
  </Step>

  <Step title="Create a token">
    Create a new API token with **read\_write** permissions. Give it a descriptive label like `CI Pipeline`.

    <Warning>
      The token is shown **once** when created. Copy it immediately and store it
      as a secret in your CI provider.
    </Warning>
  </Step>

  <Step title="Add the token to your CI secrets">
    Store the token as `LAZYLOCALES_API_KEY` in your CI provider's secret management.
  </Step>
</Steps>

## How it works

The CLI automatically checks for the `LAZYLOCALES_API_KEY` environment variable. When set, it skips interactive login and authenticates with the token instead. No config changes needed — just set the env var and run the CLI.

## GitHub Actions

```yaml .github/workflows/translate.yml theme={null}
name: Translate

on:
  push:
    branches: [main]
    paths:
      - 'public/locales/en.json'

jobs:
  translate:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - uses: actions/setup-node@v4
        with:
          node-version: 20

      - run: npm ci

      - name: Run translations
        run: npx lazylocales translate --json
        env:
          LAZYLOCALES_API_KEY: ${{ secrets.LAZYLOCALES_API_KEY }}

      - name: Commit translated files
        run: |
          git config user.name "github-actions[bot]"
          git config user.email "github-actions[bot]@users.noreply.github.com"
          git add public/locales/
          git diff --staged --quiet || git commit -m "chore: update translations"
          git push
```

## GitLab CI

```yaml .gitlab-ci.yml theme={null}
translate:
  stage: build
  image: node:20
  only:
    changes:
      - public/locales/en.json
  script:
    - npm ci
    - npx lazylocales translate --json
  variables:
    LAZYLOCALES_API_KEY: $LAZYLOCALES_API_KEY
```

## Vercel

Add `LAZYLOCALES_API_KEY` to your Vercel project environment variables, then add a prebuild step:

```json package.json theme={null}
{
  "scripts": {
    "prebuild": "npx lazylocales translate --json"
  }
}
```

## Tips

* Use `--json` flag in CI for machine-readable output and cleaner logs
* Trigger translations only when the source file changes (use path filters in your CI config)
* Use **read\_write** tokens for CI (read-only tokens cannot push source files or trigger translations)
* Commit `lazylocales.config.json` to your repo — it never contains secrets
