This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Compile .mo files from changed .po files | |
on: | |
push: | |
paths: | |
- '**/*.po' | |
branches: | |
- 'dev' | |
jobs: | |
compile_mo: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
repository: wavelog/wavelog | |
ref: dev | |
fetch-depth: 2 | |
- name: Set up gettext | |
run: sudo apt-get install -y gettext | |
- name: Compile .mo files from changed .po files | |
run: | | |
set -e | |
changed_po_files=$(git diff --name-only HEAD~1 HEAD | grep '\.po$' || true) | |
if [ -n "$changed_po_files" ]; then | |
for po in $changed_po_files; do | |
mo="${po%.po}.mo" | |
msgfmt -vv -o "$mo" "$po" | |
echo "Compiled $po to $mo" | |
done | |
else | |
echo "No .po files changed" | |
fi | |
- name: Commit changes | |
run: | | |
git config --global user.name "github-actions" | |
git config --global user.email "github-actions@github.com" | |
if [ -n "$(git status --porcelain)" ]; then | |
git add $(git ls-files --modified | grep '\.mo$') | |
git commit -m "Compiled .mo files" | |
git push | |
else | |
echo "No changes to commit" | |
fi | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |