Skip to content

Commit c9695d5

Browse files
committed
added worflow for auto conversion of po to json files
1 parent 97ecdee commit c9695d5

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Auto-convert PO to JSON and commit
2+
3+
on:
4+
push:
5+
paths:
6+
- 'po/**/*.po'
7+
8+
jobs:
9+
convert-and-commit:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v4
15+
with:
16+
persist-credentials: true
17+
fetch-depth: 0
18+
19+
- name: Set up Python
20+
uses: actions/setup-python@v5
21+
with:
22+
python-version: '3.x'
23+
24+
- name: Find changed .po files
25+
id: find_po
26+
run: |
27+
git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep '^po/.*\.po$' > changed_po_files.txt || true
28+
cat changed_po_files.txt
29+
echo "po_files<<EOF" >> $GITHUB_OUTPUT
30+
echo "$(cat changed_po_files.txt)" >> $GITHUB_OUTPUT
31+
echo "EOF" >> $GITHUB_OUTPUT
32+
33+
- name: Run conversion script
34+
if: steps.find_po.outputs.po_files != ''
35+
run: |
36+
mkdir -p locales
37+
while IFS= read -r po_file; do
38+
echo "▶ Converting $po_file"
39+
python3 convert_po_to_json.py "$po_file" "locales"
40+
done < changed_po_files.txt
41+
42+
- name: Commit and push updated JSON
43+
if: steps.find_po.outputs.po_files != ''
44+
run: |
45+
git config --global user.name "github-actions[bot]"
46+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
47+
48+
git add locales/*.json
49+
50+
if git diff --cached --quiet; then
51+
echo "✅ No JSON changes to commit."
52+
else
53+
git commit -m "chore(i18n): auto-update JSON files from updated PO files"
54+
git push origin ${{ github.ref }}
55+
echo "🚀 Pushed updated JSON files."
56+
fi

0 commit comments

Comments
 (0)