name: Crowdin Action on: push: # paths: ["app/src/main/res/**/strings.xml"] // removes filter to allow downloads at any moment. branches: [ main ] permissions: contents: write pull-requests: write jobs: # Single job so the Crowdin translation sync and the translator-placeholder seed # land in ONE pull request instead of two. The Crowdin action only downloads into # the working tree (push_translations/create_pull_request disabled); the seed # script then edits translators.json; finally one create-pull-request step opens a # single PR with both sets of changes (and no-ops when there is no diff). synchronize-with-crowdin: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v7 with: # Need tags so scripts/translators.sh can resolve the last v* release tag # for the "since last tag" window. fetch-depth: 0 - name: crowdin action uses: crowdin/github-action@v2 with: upload_sources: true upload_translations: true download_translations: true # Let the downloaded translations stay in the working tree; the single # create-pull-request step below opens the combined PR. push_translations: false create_pull_request: false env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }} CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }} # crowdin/github-action runs in a Docker container as root, so any file or # directory it downloads (especially a brand-new locale folder like # values-en-rGB/) ends up owned by root. The unprivileged runner user in # the create-pull-request step below then can't unlink those files, which # aborts its branch checkout with "unable to unlink ... Permission denied". # Reclaim ownership of the whole working tree before touching git. - name: Fix ownership after Crowdin Docker action run: sudo chown -R "$(id -u):$(id -g)" "$GITHUB_WORKSPACE" # Keep docs/changelog/translators.json seeded with everyone who has translated # recently, so the per-release `## Translations` credits (scripts/translators.sh) # can resolve them to npubs. Only adds rows when a genuinely new contributor # appears. - name: Seed translator placeholders from Crowdin run: bash scripts/translators.sh --seed env: CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }} CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }} - name: Open or update the combined Crowdin PR # peter-evans/create-pull-request is MIT-licensed CI-only tooling (not # linked into any shipped artifact). It no-ops when there is no diff. uses: peter-evans/create-pull-request@v8 with: token: ${{ secrets.GITHUB_TOKEN }} base: main branch: l10n_crowdin_translations add-paths: | amethyst/src/main/res/**/strings.xml commons/src/commonMain/composeResources/**/strings.xml docs/changelog/translators.json commit-message: 'chore: sync Crowdin translations and seed translator npub placeholders' title: 'New Crowdin Translations' body: | New Crowdin translations by [Crowdin GH Action](https://github.com/crowdin/github-action). Any new Crowdin contributors were added to `docs/changelog/translators.json` with blank npubs. Fill in the npubs you have so the next release's `## Translations` credits generate automatically via `scripts/translators.sh --from --to `.