Skip to content
Open
89 changes: 89 additions & 0 deletions .github/workflows/mobile-i18n-autofill-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: Mobile i18n Autofill (bot PR)

on:
pull_request:
branches: [dev]
paths:
- 'cmp-android/**'
- 'feature/**'
- '.github/workflows/mobile-i18n-autofill-pr.yml'
- 'translate.py'

permissions:
contents: write
pull-requests: write
Comment thread
coderabbitai[bot] marked this conversation as resolved.

jobs:
i18n-autofill:
runs-on: ubuntu-latest

Comment thread
markrizkalla marked this conversation as resolved.
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
# Checks out the actual branch of the PR
ref: ${{ github.event.pull_request.head.ref }}
token: ${{ secrets.PAT_TOKEN }}

- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'

- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Cache Gradle
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-

- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install google-genai lxml

- name: Run translation autofill
env:
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
run: |
python translate.py \
--mode apply \
--locales "ar,bn,de,en,es,fa,fr,gu,hi,hu,id,km,kn,ml,mr,ms,my,pl,pt,ru,si,sw,te,ur" \
--model "gemma-3-27b-it" \
--batch-size 15 \
--request-delay 2

- name: Validate Android resources compile
run: |
./gradlew :cmp-android:processDemoDebugResources

- name: Check for changes
id: check_changes
run: |
if git status --porcelain cmp-android/ feature/ | grep -q .; then
echo "has_changes=true" >> $GITHUB_OUTPUT
else
echo "has_changes=false" >> $GITHUB_OUTPUT
fi

- name: Commit and Push changes
if: steps.check_changes.outputs.has_changes == 'true'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"

git add cmp-android/ feature/
git commit -m "chore: auto-generate mobile i18n translations"

# Pushes directly back to the PR head branch
git push origin HEAD:${{ github.event.pull_request.head.ref }}
Loading
Loading