Files

109 lines
3.9 KiB
YAML

# SPDX-License-Identifier: AGPL-3.0-or-later
name: i18n Weblate PR
on:
workflow_dispatch:
inputs:
branch:
description: "Weblate branch to compile and open as a PR"
required: false
default: "weblate/translations"
permissions: {}
concurrency:
group: i18n-weblate-${{ github.event.inputs.branch || github.ref_name }}
cancel-in-progress: false
defaults:
run:
shell: bash
env:
WEBLATE_BRANCH: ${{ github.event.inputs.branch || github.ref_name }}
jobs:
compile:
name: compile Weblate catalogs
runs-on: ubuntu-24.04
timeout-minutes: 30
steps:
- name: Create token
id: create-token
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1
with:
client-id: ${{ vars.FLUXER_CI_APP_ID }}
private-key: ${{ secrets.FLUXER_CI_APP_KEY }}
owner: fluxerapp
repositories: fluxer
permission-contents: write
permission-pull-requests: write
- name: Checkout Weblate branch
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0
with:
token: ${{ steps.create-token.outputs.token }}
ref: ${{ env.WEBLATE_BRANCH }}
fetch-depth: 0
persist-credentials: false
- name: Set up Rust toolchain
uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9
with:
toolchain: "1.93.0"
- name: Install pnpm
uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271
- name: Install Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e
with:
node-version: "24"
cache: "pnpm"
- name: Install dependencies
run: >-
tools/ci/run.sh ci
--step install_dependencies
- name: Compile translated catalogs
run: pnpm i18n:weblate-compile
- name: Format generated catalogs
run: pnpm biome format --write package.json packages/i18n/package.json packages/i18n/scripts/SyncStaticI18nCatalogs.ts packages/errors/src/i18n fluxer_api/pkgs/email/src/email_i18n fluxer_api/src/api/content_i18n
- name: Commit generated artifacts
env:
GH_TOKEN: ${{ steps.create-token.outputs.token }}
run: |
set -euo pipefail
if [[ -z "$(git status --porcelain -- fluxer_app/src/features/i18n/locales packages/i18n/marketing packages/errors/src/i18n fluxer_api/pkgs/email/src/email_i18n fluxer_api/src/api/content_i18n)" ]]; then
echo "No generated catalog changes."
exit 0
fi
git config user.name "fluxer-ci[bot]"
git config user.email "${{ vars.FLUXER_CI_APP_USER_ID }}+fluxer-ci[bot]@users.noreply.github.com"
git add fluxer_app/src/features/i18n/locales packages/i18n/marketing packages/errors/src/i18n fluxer_api/pkgs/email/src/email_i18n fluxer_api/src/api/content_i18n
git commit -m "i18n: compile Weblate catalogs"
git remote set-url origin "https://x-access-token:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
git push origin "HEAD:$WEBLATE_BRANCH"
- name: Open Weblate PR
env:
GH_TOKEN: ${{ steps.create-token.outputs.token }}
run: |
set -euo pipefail
pr_number="$(gh pr list --base main --head "$WEBLATE_BRANCH" --state open --json number --jq '.[0].number // empty')"
body="$(cat <<'BODY'
Pulls reviewed translation updates from Weblate and includes generated runtime artifacts.
Weblate project: https://weblate.fluxer.tools/projects/fluxer/
BODY
)"
if [[ -z "$pr_number" ]]; then
gh pr create --base main --head "$WEBLATE_BRANCH" --title "chore(i18n): update translations from Weblate" --body "$body"
else
gh pr edit "$pr_number" --title "chore(i18n): update translations from Weblate" --body "$body"
fi