agama/.github/workflows/weblate-merge-po-sle16.yml
Ladislav Slezák b8709ebc68
Update GitHub Actions to the latest versions
Many Actions complain that an old Node20 code is used.
Update the actions to use newer versions.

https://github.blog/changelog/2025-09-19-deprecation-of-node-20-on-github-actions-runners/
2026-03-27 17:07:29 +01:00

128 lines
4.2 KiB
YAML

name: Weblate Merge PO (SLE-16)
permissions:
# it merges the updated translations and creates a pull request with the changes
contents: write
pull-requests: write
on:
schedule:
# run every Monday at 2:35AM UTC
- cron: "35 2 * * Mon"
# allow running manually
workflow_dispatch:
jobs:
merge-po:
# allow pushing and creating pull requests
permissions:
contents: write
pull-requests: write
# do not run in forks
if: ${{ !github.event.repository.fork }}
runs-on: ubuntu-latest
container:
image: registry.opensuse.org/opensuse/leap:16.0
volumes:
# bind mount the GitHub CLI tool from the Ubuntu host,
# it is a statically linked binary so it should work also in Leap
- /usr/bin/gh:/usr/bin/gh
steps:
- name: Configure and refresh repositories
run: |
# disable unused repositories to have a faster refresh
zypper modifyrepo -d openSUSE:repo-openh264 && zypper ref && \
zypper --non-interactive ref
- name: Install tools
run: zypper --non-interactive install --no-recommends nodejs npm git gettext-tools python3-langtable
- name: Configure Git
run: |
git config --global user.name "YaST Bot"
git config --global user.email "yast-devel@opensuse.org"
- name: Checkout sources
uses: actions/checkout@v6
with:
path: agama
# checkout the SLE-16 branch
ref: SLE-16
- name: Checkout Agama-weblate sources
uses: actions/checkout@v6
with:
path: agama-weblate
repository: ${{ github.repository_owner }}/agama-weblate
# checkout the SLE-16 branch
ref: SLE-16
- name: Install NPM packages
working-directory: ./agama/web/share/po
run: npm ci
- name: Validate the PO files
working-directory: ./agama-weblate
run: ls web/*.po | xargs -n1 msgfmt --check-format -o /dev/null
- name: Update JS translations
working-directory: ./agama
run: |
mkdir -p web/src/po
# delete the current translations
find web/src/po -name '*.js' -exec git rm '{}' ';'
# update the list of supported languages, it is used by the PO->JS converter in the next step
web/share/update-languages.py --po-directory ../agama-weblate/web > web/src/languages.json
# rebuild the JS files
(cd web/src/po && SRCDIR=../../../../agama-weblate/web ../../share/po/po-converter.js)
# stage the changes
git add web/src/po/*.js web/src/languages.json
# any changes detected?
- name: Check changes
id: check_changes
working-directory: ./agama
run: |
git diff --staged web | tee tr.diff
if [ -s tr.diff ]; then
echo "Translations updated"
# this is an Output Parameter
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-output-parameter
echo "updated=true" >> $GITHUB_OUTPUT
else
echo "Translations not changed"
echo "updated=false" >> $GITHUB_OUTPUT
fi
rm tr.diff
- name: Push updated PO files
# run only when a PO file has been updated
if: steps.check_changes.outputs.updated == 'true'
working-directory: ./agama
run: |
# use an unique branch to avoid possible conflicts with already existing branches
git checkout -b "po_merge_sle16_${GITHUB_RUN_ID}"
git commit -a -m "Update web translation files"$'\n\n'"Agama-weblate commit: `git -C ../agama-weblate rev-parse HEAD`"
git push origin "po_merge_sle16_${GITHUB_RUN_ID}"
- name: Create pull request
# run only when a PO file has been updated
if: steps.check_changes.outputs.updated == 'true'
working-directory: ./agama
run: |
gh pr create -B SLE-16 -H "po_merge_sle16_${GITHUB_RUN_ID}" \
--label translations --label bot \
--title "Update web translation files (SLE-16)" \
--body "Updating the web translation files from the agama-weblate repository"
env:
GH_TOKEN: ${{ github.token }}