Weblate - *.pot synchronization #396
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: Weblate - *.pot synchronization | |
on: | |
schedule: | |
# Run this every morning | |
- cron: '45 2 * * *' | |
workflow_dispatch: | |
jobs: | |
pot-upload: | |
name: Upload *.pot files to dnf5-l10n repository | |
# do not run the cron job on forks | |
if: (github.event_name == 'schedule' && github.repository_owner == 'rpm-software-management') || (github.event_name != 'schedule') | |
runs-on: ubuntu-latest | |
container: | |
image: ghcr.io/rpm-software-management/dnf-ci-host | |
options: --user root | |
timeout-minutes: 10 | |
steps: | |
- name: Clone source repository | |
uses: actions/checkout@v4 | |
with: | |
path: src | |
fetch-depth: 1 | |
- name: Generate fresh *.pot files | |
run: | | |
cd src | |
cmake -S . -B build | |
cmake --build build --target gettext-potfiles | |
- name: Clone weblate repository | |
uses: actions/checkout@v4 | |
with: | |
path: l10n | |
repository: ${{ github.repository }}-l10n | |
ssh-key: ${{ secrets.L10N_SSH_KEY }} | |
- name: Commit .pot to weblate repo | |
run: | | |
git config --global user.name "GitHub Workflow" | |
git config --global user.email "[email protected]" | |
pushd src | |
for f in $(find * -type f -name "*.pot"); do | |
potfile=$(basename $f) | |
component=${potfile%.*} | |
mkdir -p ../l10n/${component} | |
cp ${f} ../l10n/${component}/${potfile} | |
echo ${f%/*} > ../l10n/${component}/PATH | |
done | |
popd | |
git -C l10n add "*" | |
# If only creation dates were changed do nothing | |
if git -C l10n diff --staged --ignore-matching-lines='"POT-Creation-Date:' --exit-code; then exit 0; fi | |
git -C l10n commit -m "Update source files" | |
git -C l10n push |