Skip to content

Commit

Permalink
Merge branch 'master' into improve-page-and-layout
Browse files Browse the repository at this point in the history
  • Loading branch information
dgdavid committed Dec 15, 2023
2 parents 9fd2bd6 + 8e1c1d1 commit 5bc9b35
Show file tree
Hide file tree
Showing 21 changed files with 795 additions and 173 deletions.
111 changes: 111 additions & 0 deletions .github/workflows/weblate-merge-service-po.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
name: Weblate Merge Service PO

on:
schedule:
# run every Monday at 2:45AM UTC
- cron: "45 2 * * 0"

# 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.repository_owner == 'openSUSE'

runs-on: ubuntu-latest

container:
image: registry.opensuse.org/opensuse/tumbleweed:latest
volumes:
# bind mount the GitHub CLI tool from the Ubuntu host,
# it is a statically linked binary so it should work everywhere
- /usr/bin/gh:/usr/bin/gh

steps:
- name: Configure and refresh repositories
run: |
# disable unused repositories to have a faster refresh
zypper modifyrepo -d repo-non-oss repo-openh264 repo-update && \
zypper --non-interactive --gpg-auto-import-keys ref
- name: Install tools
run: zypper --non-interactive install --no-recommends git gettext-tools

- name: Configure Git
run: |
git config --global user.name "YaST Bot"
git config --global user.email "[email protected]"
- name: Checkout sources
uses: actions/checkout@v3
with:
path: agama

- name: Checkout Agama-weblate sources
uses: actions/checkout@v3
with:
path: agama-weblate
repository: openSUSE/agama-weblate

- name: Validate the service PO files
working-directory: ./agama-weblate
run: ls service/*.po | xargs -n1 msgfmt --check-format -o /dev/null

- name: Update PO files
working-directory: ./agama
run: |
mkdir -p service/po
# delete the current translations
find service/po -name '*.po' -exec git rm '{}' ';'
# copy the new ones
cp -a ../agama-weblate/service/*.po service/po
git add service/po/*.po
# any changes besides the timestamps in the PO files?
- name: Check changes
id: check_changes
working-directory: ./agama
run: |
git diff --staged --ignore-matching-lines="POT-Creation-Date:" \
--ignore-matching-lines="PO-Revision-Date:" service/po > po.diff
if [ -s po.diff ]; then
echo "PO files updated"
# this is an Output Parameter
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-output-parameter
echo "po_updated=true" >> $GITHUB_OUTPUT
else
echo "PO files unchanged"
echo "po_updated=false" >> $GITHUB_OUTPUT
fi
rm po.diff
- name: Push updated PO files
# run only when a PO file has been updated
if: steps.check_changes.outputs.po_updated == 'true'
working-directory: ./agama
run: |
# use a unique branch to avoid possible conflicts with already existing branches
git checkout -b "po_service_merge_${GITHUB_RUN_ID}"
git commit -a -m "Update service PO files"$'\n\n'"Agama-weblate commit: `git -C ../agama-weblate rev-parse HEAD`"
git push origin "po_service_merge_${GITHUB_RUN_ID}"
- name: Create pull request
# run only when a PO file has been updated
if: steps.check_changes.outputs.po_updated == 'true'
working-directory: ./agama
run: |
gh pr create -B master -H "po_service_merge_${GITHUB_RUN_ID}" \
--label translations --label bot \
--title "Update service PO files" \
--body "Updating the service translation files from the agama-weblate repository"
env:
GH_TOKEN: ${{ github.token }}
6 changes: 3 additions & 3 deletions .github/workflows/weblate-update-pot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,17 +144,17 @@ jobs:
- name: Generate service POT file
run: |
cd agama/service
cd agama
rake pot
msgfmt --statistics agama.pot
- name: Validate the generated service POT file
run: msgfmt --check-format agama/service/agama.pot
run: msgfmt --check-format agama/agama.pot

- name: Update service POT file
run: |
mkdir -p agama-weblate/service
cp agama/service/agama.pot agama-weblate/service/agama.pot
cp agama/agama.pot agama-weblate/service/agama.pot
# any change besides the timestamp in the POT file?
- name: Check service POT changes
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.log/
.yardoc/
.vscode/tasks.json
/*.pot
Loading

0 comments on commit 5bc9b35

Please sign in to comment.