Book Creation Wizard #577
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| permissions: | |
| contents: write | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: pnpm/action-setup@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| cache: pnpm | |
| - run: pnpm install --frozen-lockfile | |
| - run: pnpm typecheck | |
| - run: pnpm test | |
| docker: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Build Docker api target | |
| run: docker build --target api . | |
| i18n: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: pnpm/action-setup@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| cache: pnpm | |
| - run: pnpm install --frozen-lockfile | |
| - name: Check for unlocalized strings | |
| run: | | |
| pnpm --filter @adt/studio extract | |
| NEW=$(git diff -- apps/studio/src/locales/ | grep '^+msgid "' | grep -v '^+msgid ""' || true) | |
| if [ -n "$NEW" ]; then | |
| echo "New unextracted strings found. Run 'pnpm --filter @adt/studio extract' and commit the updated .po files." | |
| echo "$NEW" | |
| exit 1 | |
| fi | |
| - name: Check for stale keys in non-source locales | |
| run: | | |
| for po in apps/studio/src/locales/*.po; do | |
| locale=$(basename "$po" .po) | |
| if [ "$locale" = "en" ]; then continue; fi | |
| count=$(grep -c "^#~ msgid" "$po" || true) | |
| if [ "$count" -gt 0 ]; then | |
| echo "::warning file=$po::$locale has $count stale key(s) no longer in source (en) — run 'pnpm --filter @adt/studio extract' to clean up" | |
| grep "^#~ msgid" "$po" | sed "s/^#~ msgid /#~[$locale] /" | |
| fi | |
| done | |
| - name: Check translations are up to date | |
| id: compile | |
| run: pnpm --filter @adt/studio compile --strict | |
| continue-on-error: true | |
| - name: Warn about missing translations | |
| if: steps.compile.outcome == 'failure' | |
| run: | | |
| for po in apps/studio/src/locales/*.po; do | |
| locale=$(basename "$po" .po) | |
| if [ "$locale" = "en" ]; then continue; fi | |
| count=$(grep -c '^msgstr ""' "$po" || true) | |
| if [ "$count" -gt 0 ]; then | |
| echo "::warning file=$po::$locale is missing $count translation(s) — triggering auto-translate" | |
| fi | |
| done | |
| - name: Auto-translate missing strings | |
| if: steps.compile.outcome == 'failure' | |
| env: | |
| OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | |
| TRANSLATE_MODEL: ${{ secrets.TRANSLATE_MODEL }} | |
| run: | | |
| if [ -z "$OPENAI_API_KEY" ]; then | |
| echo "OPENAI_API_KEY not set — cannot auto-translate" | |
| exit 1 | |
| fi | |
| pnpm --filter @adt/studio translate:missing | |
| if ! git diff --quiet apps/studio/src/locales/; then | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add apps/studio/src/locales/ | |
| git commit -m "chore(i18n): auto-translate missing strings via OpenAI API" | |
| git fetch origin ${{ github.head_ref }} | |
| git rebase origin/${{ github.head_ref }} | |
| git push origin HEAD:${{ github.head_ref }} | |
| fi | |
| - name: Verify translations after auto-translate | |
| if: steps.compile.outcome == 'failure' | |
| run: pnpm --filter @adt/studio compile --strict | |
| - name: Check for hardcoded strings | |
| run: pnpm --filter @adt/studio lint |