File tree Expand file tree Collapse file tree 1 file changed +56
-0
lines changed Expand file tree Collapse file tree 1 file changed +56
-0
lines changed Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments