virt-manager/.github/workflows/translations.yml
Pavel Hrdina c385cd4eb7 ci: update github workflows to use meson
Running `meson dist` requires working git but that doesn't seem to be the
default in github actions when running jobs inside container. Any git
invocation fails with the following error:

fatal: detected dubious ownership in repository at '/__w/virt-manager/virt-manager'
To add an exception for this directory, call:

	git config --global --add safe.directory /__w/virt-manager/virt-manager

So that's what this patch does to make `meson dist` work correctly.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2024-11-12 23:18:32 +01:00

69 lines
1.9 KiB
YAML

name: Translations
on:
schedule:
# Implicitly runs on default branch
# every two days at 6:00 UTC
- cron: '0 6 */2 * *'
jobs:
# This job will run meson compile -C build virt-manager-pot on top of git main
# and force push that to the 'translations' branch. That branch will
# always have an up to date .pot file for use in weblate
update-translation-pot:
# Only run this if on the main 'virt-manager/virt-manager' repo, not forks
if: "contains(github.repository, 'virt-manager/virt-manager')"
runs-on: ubuntu-latest
container:
image: fedora:latest
steps:
- name: Install deps
run: |
dnf install -y \
git \
diffutils \
gettext \
python3-devel \
python3-docutils \
meson
- uses: actions/checkout@v4
with:
# This fetches full git history. We need that for proper
# branch updating
fetch-depth: 0
- name: Extract messages and push to translations branch
run: |
git config --global user.email "actions@github.com"
git config --global user.name "Github Actions"
git fetch --all
git rebase remotes/origin/translations
cp po/virt-manager.pot old.pot
meson setup build \
-Dupdate-icon-cache=false \
-Dcompile-schemas=false \
-Dtests=disabled
meson compile -C build virt-manager-pot
ec=0
diff -q -I 'POT-Creation-Date' old.pot po/virt-manager.pot || ec=$?
case "${ec}" in
0) ;;
1)
git commit po/virt-manager.pot \
--message "Refresh translation .pot template"
remote_repo="https://${GITHUB_ACTOR}:${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git"
git push "${remote_repo}" HEAD:translations
;;
*)
echo "diff failed with exit status ${ec}" >&2
exit 1
;;
esac