From c8faad0acf6963c38e90c819c433f1e72b391fa1 Mon Sep 17 00:00:00 2001 From: Hayden <64056131+hay-kot@users.noreply.github.com> Date: Fri, 4 Jul 2025 11:43:49 -0500 Subject: [PATCH] auto-updating workflow for crowding % values --- .github/workflows/locale-sync.yml | 103 ++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 .github/workflows/locale-sync.yml diff --git a/.github/workflows/locale-sync.yml b/.github/workflows/locale-sync.yml new file mode 100644 index 000000000..f76d1e4bd --- /dev/null +++ b/.github/workflows/locale-sync.yml @@ -0,0 +1,103 @@ +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 + +jobs: + sync-locales: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.12' + + - name: Install Poetry + uses: snok/install-poetry@v1 + with: + virtualenvs-create: true + virtualenvs-in-project: true + + - name: Load cached venv + id: cached-poetry-dependencies + uses: actions/cache@v4 + with: + path: .venv + key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }} + + - name: Check venv cache + id: cache-validate + if: steps.cached-poetry-dependencies.outputs.cache-hit == 'true' + run: | + echo "import fastapi;print('venv good?')" > test.py && poetry 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 + poetry install + if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' + + - name: Run locale generation + run: | + cd dev/code-generation + poetry run python main.py locales + env: + CROWDIN_API_KEY: ${{ secrets.CROWDIN_API_KEY }} + + - 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" + + # Create a new 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: automatic locale sync" + + # Push the branch + git push origin "$BRANCH_NAME" + + # Create PR using GitHub CLI + gh pr create --title "chore: automatic locale sync" --body "## Summary + + Automatically generated locale updates from the weekly sync job. + + ## Changes + - Updated frontend locale files + - Generated from latest translation sources + + ## Test plan + - [ ] Verify locale files are properly formatted + - [ ] Test that translations load correctly in the frontend" --base dev --head "$BRANCH_NAME" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: No changes detected + if: steps.changes.outputs.has_changes == 'false' + run: echo "No locale changes detected, skipping PR creation"