GitHub Action
A composite action (integrations/ci/github-action/action.yml) with no third-party actions inside. It is not on the Marketplace: use it from a checkout of the repository. Syntax details are verify (see the overview).
# .github/workflows/translate.yml
name: Translate
on:
pull_request:
paths: ['resilientlang/strings.json']
push:
branches: [main]
paths: ['resilientlang/strings.json']
permissions:
contents: read
pull-requests: write # only to post the preview comment
concurrency: { group: resilientlang, cancel-in-progress: false }
jobs:
translate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4 # pin to a full commit sha in production
# ...your step that writes resilientlang/strings.json...
- uses: ./integrations/ci/github-action
with:
api-url: https://api.example.com # your control-plane URL
api-key: ${{ github.event_name == 'pull_request' && secrets.RL_API_KEY_READONLY || secrets.RL_API_KEY }}
site: ${{ vars.RL_SITE }}
What it does#
- Push, schedule or manual dispatch:
rl push, thenrl translate --wait, thenrl publish --wait. Outputs:version(the published manifest version),stored(new strings) andsummary-file. - Pull request: a dry run that writes nothing to the control plane. It reads the site's strings (
rl export), counts new strings, changed strings (edited text, only where a uniquecontextsuch as a message id links the old and new text) and estimated words (placeholders and tags excluded, per language and times the site's target languages), shows the remaining AI words if the server reports them, and posts one comment (found again by a hidden marker and updated on every push) plus the job summary. The key is never in the comment. How the plan counts words across several languages is verify; the comment shows the basis it used.
Inputs#
api-url, api-key, site, strings-file (default resilientlang/strings.json; a JSON array, {"items":[]} or one string per line), languages, mode (auto, sync or preview), publish, translate, timeout, on-unavailable (fail or warn), comment, github-token, rl-cli.
Failures#
Failures become ::error annotations with a title and the fix (see Troubleshooting CI runs). A read-only GITHUB_TOKEN, as on fork pull requests, only downgrades the comment to a warning.
Keep the two-key rule: the expression above gives pull requests the read-only key and the default branch the write key. Never use pull_request_target with a checkout of the pull request's code.