prevent workflow failure if there are no changes in the language files #6
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: Automatic synchronization of related languages | |
on: | |
push: | |
branches: | |
- main | |
- master | |
workflow_dispatch: # Allows manual trigger | |
jobs: | |
sync-translations: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Install gettext (for msgfmt) | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y gettext | |
- name: Copy and adjust de_AT translation files | |
run: | | |
mkdir -p ./languages | |
# Copy and adjust the .po file | |
cp ./languages/wppedia-de_DE.po ./languages/wppedia-de_AT.po | |
sed -i 's/Language: de_DE/Language: de_AT/' ./languages/wppedia-de_AT.po | |
sed -i 's/Language-Team: Deutsch/Language-Team: Österreichisches Deutsch/' ./languages/wppedia-de_AT.po | |
# Recompile the .mo file for de_AT | |
msgfmt ./languages/wppedia-de_AT.po -o ./languages/wppedia-de_AT.mo | |
- name: Copy and adjust de_CH translation files | |
run: | | |
# Copy and adjust the .po file | |
cp ./languages/wppedia-de_DE.po ./languages/wppedia-de_CH.po | |
sed -i 's/Language: de_DE/Language: de_CH/' ./languages/wppedia-de_CH.po | |
sed -i 's/Language-Team: Deutsch/Language-Team: Schweizerdeutsch/' ./languages/wppedia-de_CH.po | |
# Recompile the .mo file for de_CH | |
msgfmt ./languages/wppedia-de_CH.po -o ./languages/wppedia-de_CH.mo | |
- name: Commit changes (if any) | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
# Check for changes | |
if [[ -n "$(git status --porcelain)" ]]; then | |
git add . | |
git commit -m "🔄 Sync translation files for de_AT and de_CH" | |
git push | |
else | |
echo "No changes to commit." | |
fi | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |