Skip to content

Eyedropper and More Documentation for Lego Bricks (#4759) #1

Eyedropper and More Documentation for Lego Bricks (#4759)

Eyedropper and More Documentation for Lego Bricks (#4759) #1

name: Auto-convert PO to JSON and commit
on:
push:
paths:
- 'po/**/*.po'
jobs:
convert-and-commit:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
persist-credentials: true
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Find changed .po files
id: find_po
run: |
git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep '^po/.*\.po$' > changed_po_files.txt || true
cat changed_po_files.txt
echo "po_files<<EOF" >> $GITHUB_OUTPUT
echo "$(cat changed_po_files.txt)" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Run conversion script
if: steps.find_po.outputs.po_files != ''
run: |
mkdir -p locales
while IFS= read -r po_file; do
echo "▶ Converting $po_file"
python3 convert_po_to_json.py "$po_file" "locales"
done < changed_po_files.txt
- name: Commit and push updated JSON
if: steps.find_po.outputs.po_files != ''
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add locales/*.json
if git diff --cached --quiet; then
echo "✅ No JSON changes to commit."
else
git commit -m "chore(i18n): auto-update JSON files from updated PO files"
git push origin ${{ github.ref }}
echo "🚀 Pushed updated JSON files."
fi