Skip to page
LocaleasySecurity

CI

A pipeline pushes the source texts when they change, pulls translations back into a pull request, and stops a build that would ship broken or missing texts.

What a pipeline needs

  • localeasy.json and localeasy.lock, committed. See Config.
  • An API key in LOCALEASY_TOKEN, kept as a secret. Make it in Settings › API keys with the write scope, or read for a job that only pulls or reads status. A key can be bound to one project and to a branch pattern, and always has an expiry date. On GitHub Actions a repository with CI access needs no key: see Without a stored key.
  • Node.js 22.12 or newer. The action sets up Node.js 24 itself.

check needs no token: it reads only the files in the repository.

The GitHub Action

The action runs one CLI command, and can open a pull request with the files the command changed.

The action and the CLI are pre-releases and are not published yet: localeasy/action@v1 does not exist on GitHub, and the CLI is not on npm. Until they are, copy the action's action.yml from Localeasy's repository (packages/action/) into yours, for example to .github/actions/localeasy/, use it as uses: ./.github/actions/localeasy, and point its cli input at a CLI packed as Install describes. The recipes below are written as they will read once both are published.

The action's inputs
InputDefaultWhat it is
commandpushThe CLI command and its flags, such as pull --state approved.
create_pull_requestfalsetrue opens a pull request with the files the command changed, or updates the one that is open.
pr_branchlocaleasy/translationsThe pull request's branch.
pr_baseemptyThe branch the pull request targets. Empty is the branch checked out.
clilocaleasy@0.1.0-alpha.0The npm package to run the CLI from: a version, or a path to a packed tarball.

Pass the API key as env on the step. The action sets up Node.js 24, which later steps of the job use too.

Recipes

Push the source texts on every merge to main

on:
  push:
    branches: [main]

jobs:
  push:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - uses: localeasy/action@v1
        env:
          LOCALEASY_TOKEN: ${{ secrets.LOCALEASY_TOKEN }}

The push updates localeasy.lock in the job's checkout only, which is fine: a file the lockfile does not vouch for is compared with the server and sent only if it differs.

An entry in the lockfile vouches only for the server, project and branch it names. A lockfile committed on a feature branch after a push there does not stop this job from sending the file to main. See Config.

Only main and master are the main line. For a default branch with another name, such as develop, set the step's command input to push --branch main. Without it the push goes to a branch called develop.

Pull approved translations into a pull request every night

on:
  schedule:
    - cron: "0 3 * * *"
  workflow_dispatch:

permissions:
  contents: write
  pull-requests: write

jobs:
  pull:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - uses: localeasy/action@v1
        with:
          command: pull --state approved
          create_pull_request: true
        env:
          LOCALEASY_TOKEN: ${{ secrets.LOCALEASY_TOKEN }}
  • The repository must allow GitHub Actions to create pull requests: Settings → Actions → General → Workflow permissions. An organisation can switch that off for all its repositories.
  • The pull request stays open on localeasy/translations, and each run updates it.
  • GitHub does not start other workflows for a pull request the workflow's own token opened, so checks on it wait until someone pushes to the branch.

Check the translation files on every pull request

on: pull_request

jobs:
  check:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - uses: localeasy/action@v1
        with:
          command: check --reporter github

Findings show as annotations on the pull request. An error fails the job with exit 3.

Without a stored key

on:
  push:
    branches: [main]

permissions:
  contents: read
  id-token: write

jobs:
  push:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - uses: localeasy/action@v1

With id-token: write and no LOCALEASY_TOKEN, the CLI asks GitHub for the job's OIDC token, made out to the server's address, and exchanges it for a 15-minute access token as it does an API key. The server checks GitHub's signature and takes the token only for a repository an owner or admin gave CI access. That access names:

  • The repository by GitHub's ids, so a renamed repository keeps it and a new one with the old name doesn't get it. gh api repos/OWNER/NAME --jq '.id, .owner.id' prints them.
  • The projects its runs reach, its scopes and its role, as an API key's.
  • Optionally a ref pattern, such as refs/heads/main or refs/tags/v*, a GitHub environment the job must run in, and a branch pattern for what it may write.

An owner or admin gives it from a signed-in session in the app, never with an API key, one per repository in an organisation. The app has no screen for it yet. Revoking it stops the tokens it gave at once, and the audit log records both. The CLI sends the project its localeasy.json names, and the token is from the organisation whose access lists that project, so another organisation giving the same repository access changes nothing for yours. Its token is limited to its projects: it can't create or delete projects, read the organisation's audit log or erase keys, whatever its role.

GitHub gives no OIDC token to a pull_request run from a fork. A pull_request_target run gets one for the base branch, so a ref pattern of refs/heads/main lets it in: such a workflow that checks out the fork's code would push it with the access's scopes. Don't run the CLI in one.

The plain CLI

The action is a thin wrapper. Anywhere Node.js runs, the same steps are CLI commands with LOCALEASY_TOKEN in the environment. In GitLab CI:

localeasy-check:
  image: node:24
  rules:
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"
  script:
    - npx localeasy check

localeasy-push:
  image: node:24
  rules:
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
  script:
    - npx localeasy push

Set LOCALEASY_TOKEN as a masked CI/CD variable. npx localeasy works once the CLI is published; until then run the packed file as Install describes.

  • Outside a terminal the CLI asks nothing. Colour is on in GitHub Actions and GitLab CI.
  • --json prints one JSON object per command, for a script to read. See Output.
  • The CLI retries a rate-limited or unavailable server three times before it gives up with exit 75 or 69. Both are safe to run again.

Gates

Three commands exit 3 when they find something, and change nothing. A pipeline that treats any exit code but 0 as a failure needs nothing more.

Commands that gate a pipeline
CommandExits 3 whenNeeds a token
localeasy checkA file does not parse, a message is invalid, or a translation's placeholders differ from the source text's.No
localeasy pull --frozenA committed translation file differs from what the server would write.Yes
localeasy status --fail-under 95A language's fresh share is under 95%. With --state approved, only approved translations count.Yes

Exit codes lists every code. 4 is a conflict; 64 and above mean the command could not do its work.

Branches and pull requests

In CI the CLI works on the branch the pipeline builds; on a GitHub pull request that is the pull request's branch. A push from a pull request therefore goes to a Localeasy branch of the same name, and opens it if it is new. main and master are the main line.

Three commands cover a pull request's life:

# On each push to the pull request: send its source texts to its branch.
localeasy push

# As a check on the pull request: would the branch merge?
localeasy merge --dry-run

# Once the pull request is merged: merge the branch, and record where it came from.
localeasy merge --git-sha <sha> --pr-url <url>

The last one must run where the CLI still sees the pull request's branch, or with the branch named: localeasy merge feature/checkout. A job on the default branch resolves to the main line, which has nothing to merge.

  • merge --dry-run fails the check with exit 4 while the branch conflicts with main, and lists the conflicts. Conflicts says how to settle them.
  • A merge that already happened answers that it was already merged, with exit 0.
  • A push from a pull request removes no keys, also with --remove-missing: that flag acts on the main line. See Removing keys.
  • A project has a limit on open branches, and a branch nobody writes to expires. See Limits.

Instead of the merge job, a git connection can do the merge: in the project's Settings › Git connections, connect the GitHub or GitLab repository. When a pull request into the default branch is merged, Localeasy merges the branch of the same name, if the connection is trusted to merge. When it is closed without merging, the branch is closed.