mirror of
https://github.com/twentyhq/twenty
synced 2026-04-21 13:37:22 +00:00
## Summary - **Add `lingui:compile` to Dockerfile** before both the server and frontend build stages, ensuring compiled translation catalogs are always fresh regardless of git state - **Add `repository-dispatch` to i18n workflows** (`i18n-push.yaml` and `i18n-pull.yaml`) to trigger reactive automerge in `twenty-infra` when the i18n PR is ready, replacing the 15-minute polling approach ## Context Users sometimes see "Uncompiled message detected" errors because releases can be cut from `main` before the i18n PR (with freshly compiled translation catalogs) has been merged. This creates a race condition between new translatable strings landing on `main` and their compiled catalogs being available. These changes fix this in two ways: 1. **Safety net in builds**: Every Docker build now compiles translations before building, so even if compiled catalogs in git are stale, the build artifact is always correct 2. **Faster i18n PR merges**: Instead of a 15-minute cron polling for i18n PRs, the workflows now notify `twenty-infra` immediately when translations are ready, reducing merge latency from ~15 minutes to ~1 minute Companion PR in twenty-infra: twentyhq/twenty-infra (feat/i18n-reactive-automerge) ## Test plan - [ ] Verify `TWENTY_INFRA_TOKEN` secret is available to i18n workflows - [ ] Docker build still succeeds with the added `lingui:compile` steps - [ ] i18n-push triggers automerge in twenty-infra after pushing changes - [ ] i18n-pull triggers automerge in twenty-infra after pulling translations Made with [Cursor](https://cursor.com)
112 lines
3.9 KiB
YAML
112 lines
3.9 KiB
YAML
name: 'Push translations to Crowdin'
|
|
|
|
permissions:
|
|
contents: write
|
|
pull-requests: write
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
workflow_call:
|
|
push:
|
|
branches: ['main']
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
|
|
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
|
|
|
|
jobs:
|
|
extract_translations:
|
|
name: Extract and upload translations
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
token: ${{ github.token }}
|
|
ref: main
|
|
|
|
- name: Setup i18n branch
|
|
run: |
|
|
git fetch origin i18n || true
|
|
git checkout -B i18n origin/i18n || git checkout -b i18n
|
|
|
|
- name: Install dependencies
|
|
uses: ./.github/actions/yarn-install
|
|
|
|
- name: Build dependencies
|
|
run: npx nx build twenty-shared
|
|
|
|
- name: Extract translations
|
|
run: |
|
|
npx nx run twenty-server:lingui:extract
|
|
npx nx run twenty-emails:lingui:extract
|
|
npx nx run twenty-front:lingui:extract
|
|
|
|
- name: Check and commit extracted files
|
|
id: check_extract_changes
|
|
run: |
|
|
git config --global user.name 'github-actions'
|
|
git config --global user.email 'github-actions@twenty.com'
|
|
git add .
|
|
if ! git diff --staged --quiet --exit-code; then
|
|
git commit -m "chore: extract translations"
|
|
echo "changes_detected=true" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "changes_detected=false" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
- name: Compile translations
|
|
run: |
|
|
npx nx run twenty-server:lingui:compile
|
|
npx nx run twenty-emails:lingui:compile
|
|
npx nx run twenty-front:lingui:compile
|
|
|
|
- name: Check and commit compiled files
|
|
id: check_compile_changes
|
|
run: |
|
|
git config --global user.name 'github-actions'
|
|
git config --global user.email 'github-actions@twenty.com'
|
|
git add .
|
|
if ! git diff --staged --quiet --exit-code; then
|
|
git commit -m "chore: compile translations"
|
|
echo "changes_detected=true" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "changes_detected=false" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
- name: Push changes and create remote branch if needed
|
|
if: steps.check_extract_changes.outputs.changes_detected == 'true' || steps.check_compile_changes.outputs.changes_detected == 'true'
|
|
run: git push origin HEAD:i18n
|
|
|
|
- name: Upload missing translations
|
|
if: steps.check_extract_changes.outputs.changes_detected == 'true'
|
|
uses: crowdin/github-action@v2
|
|
with:
|
|
upload_sources: true
|
|
upload_translations: true
|
|
download_translations: false
|
|
localization_branch_name: i18n
|
|
base_url: 'https://twenty.api.crowdin.com'
|
|
config: '.github/crowdin-app.yml'
|
|
env:
|
|
# App translations project
|
|
CROWDIN_PROJECT_ID: '1'
|
|
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
|
|
- name: Create a pull request
|
|
if: steps.check_extract_changes.outputs.changes_detected == 'true' || steps.check_compile_changes.outputs.changes_detected == 'true'
|
|
run: |
|
|
if git diff --name-only origin/main..HEAD | grep -q .; then
|
|
gh pr create -B main -H i18n --title 'i18n - translations' --body 'Created by Github action' || true
|
|
else
|
|
echo "No file differences between branches, skipping PR creation"
|
|
fi
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Trigger i18n automerge
|
|
if: steps.check_extract_changes.outputs.changes_detected == 'true' || steps.check_compile_changes.outputs.changes_detected == 'true'
|
|
uses: peter-evans/repository-dispatch@v2
|
|
with:
|
|
token: ${{ secrets.TWENTY_INFRA_TOKEN }}
|
|
repository: twentyhq/twenty-infra
|
|
event-type: i18n-pr-ready
|