GitHub Actions Integration
Prerequisites
1. Configure Repository Secrets
Lara CLI authenticates with the translation API using credentials stored as GitHub Secrets.
- Go to your repository Settings > Secrets and variables > Actions.
- Click New repository secret.
- Add the following secrets (values available in your Lara account dashboard):
LARA_ACCESS_KEY_IDLARA_ACCESS_KEY_SECRET
2. Configure Workflow Permissions
The action needs write access to commit translated files back to your repository.
- Go to Settings > Actions > General.
- Scroll to Workflow permissions.
- Select Read and write permissions.
- Click Save.
3. Ensure a Local Configuration Exists
Before using the GitHub Action, run lara-cli init locally and push the generated lara.yaml file to your repository. The CI workflow runs in non-interactive mode and requires this file to be present.
Workflow Configuration
Create the file .github/workflows/translate.yml in your repository with the following content:
name: Lara Translation Workflow
on:
workflow_dispatch:
push:
branches:
- main
jobs:
translate-codebase:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
- name: Setup PNPM
uses: pnpm/action-setup@v2
with:
version: 8
- name: Install Lara CLI
run: pnpm install -g @translated/lara-cli
- name: Run Lara Translate
env:
LARA_ACCESS_KEY_ID: ${{ secrets.LARA_ACCESS_KEY_ID }}
LARA_ACCESS_KEY_SECRET: ${{ secrets.LARA_ACCESS_KEY_SECRET }}
run: lara-cli translate
- name: Commit translations
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "chore: update translations via Lara CLI"How It Works
- Setup — The workflow installs Node.js v18 and PNPM v8.
- Installation — Lara CLI is installed globally from the npm registry.
- Translation —
lara-cli translateruns using the credentials stored in your GitHub Secrets. Thelara.yamlconfiguration file in your repository controls which files are translated and into which languages. - Auto-commit — Any updated translation files are automatically committed and pushed back to your
mainbranch.
