name: Generate Translation Strings on: push: branches: - dev env: DEFAULT_UV_VERSION: "0.11.x" jobs: generate-translate-strings: name: Generate Translation Strings runs-on: ubuntu-latest environment: translation-sync permissions: contents: write steps: - name: Checkout code uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 env: GH_REF: ${{ github.ref }} # sonar rule:githubactions:S7630 - avoid injection with: token: ${{ secrets.PNGX_BOT_PAT }} ref: ${{ env.GH_REF }} persist-credentials: true # for pushing translation branch - name: Set up Python id: setup-python uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 - name: Install system dependencies run: | sudo apt-get update -qq sudo apt-get install -qq --no-install-recommends gettext - name: Install uv uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0 with: version: ${{ env.DEFAULT_UV_VERSION }} enable-cache: true - name: Install backend python dependencies run: | uv sync \ --group dev \ --frozen - name: Generate backend translation strings env: PAPERLESS_SECRET_KEY: "ci-translate-not-a-real-secret" run: cd src/ && uv run manage.py makemessages -l en_US -i "samples*" - name: Install pnpm uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9 with: version: 10 - name: Use Node.js 24 uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 with: node-version: 24.x cache: 'pnpm' cache-dependency-path: 'src-ui/pnpm-lock.yaml' - name: Cache frontend dependencies id: cache-frontend-deps uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 with: path: | ~/.pnpm-store ~/.cache key: ${{ runner.os }}-frontenddeps-${{ hashFiles('src-ui/pnpm-lock.yaml') }} - name: Install frontend dependencies if: steps.cache-frontend-deps.outputs.cache-hit != 'true' run: cd src-ui && pnpm install - name: Re-link Angular cli run: cd src-ui && pnpm link @angular/cli - name: Generate frontend translation strings run: | cd src-ui pnpm run ng extract-i18n - name: Commit changes uses: stefanzweifel/git-auto-commit-action@4a55954c782fc1ea30b9056cd3e7a2b40ca8887d # v7.2.0 with: file_pattern: 'src-ui/messages.xlf src/locale/en_US/LC_MESSAGES/django.po' commit_message: "Auto translate strings" commit_user_name: "GitHub Actions" commit_author: "GitHub Actions <41898282+github-actions[bot]@users.noreply.github.com>"