name: Automatic Locale Sync on: schedule: # Run every Sunday at 2 AM UTC - cron: "0 2 * * 0" workflow_dispatch: # Allow manual triggering from the GitHub UI permissions: contents: write # To checkout, commit, and push changes pull-requests: write # To create pull requests jobs: sync-locales: runs-on: ubuntu-latest env: # Install from the committed lockfile; never re-resolve (see pyproject # [tool.uv] exclude-newer cooling window). UV_FROZEN: "1" steps: - name: Generate GitHub App Token id: app-token uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3 with: app-id: ${{ secrets.COMMIT_BOT_APP_ID }} private-key: ${{ secrets.COMMIT_BOT_APP_PRIVATE_KEY }} - name: Checkout repository uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 with: token: ${{ steps.app-token.outputs.token }} - name: Set up tools uses: ./.github/actions/setup-tools with: tools: python uv - name: Load cached venv id: cached-python-dependencies uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6 with: # The venv links to the mise Python, so a Python change in mise.toml must miss the cache path: .venv key: venv-${{ runner.os }}-${{ hashFiles('**/uv.lock', 'mise.toml') }} - name: Check venv cache id: cache-validate if: steps.cached-python-dependencies.outputs.cache-hit == 'true' run: | echo "import fastapi;print('venv good?')" > test.py && uv run python test.py && echo "cache-hit-success=true" >> $GITHUB_OUTPUT rm test.py continue-on-error: true - name: Install dependencies run: | sudo apt-get update sudo apt-get install libsasl2-dev libldap2-dev libssl-dev uv sync --group dev if: steps.cached-python-dependencies.outputs.cache-hit != 'true' - name: Remove Crowdin approvals and run locale generation run: | cd dev/code-generation uv run python main.py crowdin-approvals locales env: CROWDIN_API_KEY: ${{ secrets.CROWDIN_API_KEY }} # Codegen imports mealie, which otherwise defaults to production and its /app data dir PRODUCTION: "false" - name: Check for changes id: changes run: | if git diff --quiet; then echo "has_changes=false" >> $GITHUB_OUTPUT else echo "has_changes=true" >> $GITHUB_OUTPUT fi - name: Commit and create PR if: steps.changes.outputs.has_changes == 'true' run: | # Configure git git config --local user.email "action@github.com" git config --local user.name "GitHub Action" # Use the current branch as the base BASE_BRANCH="${{ github.ref_name }}" echo "Using base branch: $BASE_BRANCH" # Create a new branch from the base branch BRANCH_NAME="auto-locale-sync-$(date +%Y%m%d-%H%M%S)" git checkout -b "$BRANCH_NAME" # Add and commit changes git add . git commit -m "chore: crowdin locale sync" # Push the branch git push origin "$BRANCH_NAME" sleep 2 # Create PR using GitHub CLI with explicit repository gh pr create \ --repo "${{ github.repository }}" \ --title "chore(l10n): Crowdin locale sync" \ --base "$BASE_BRANCH" \ --head "$BRANCH_NAME" \ --label "l10n" \ --body "## Summary Automatically generated locale updates from the weekly sync job. ## Changes - Updated frontend locale files - Generated from latest translation sources" \ env: GH_TOKEN: ${{ steps.app-token.outputs.token }} - name: No changes detected if: steps.changes.outputs.has_changes == 'false' run: echo "No locale changes detected, skipping PR creation"