workflow adjustments to reduce commits

This commit is contained in:
HB9HIL
2024-07-12 22:53:39 +02:00
parent 8621980b28
commit 88d79d09f4
4 changed files with 27 additions and 58 deletions

View File

@@ -1,51 +0,0 @@
name: Compile .mo files from changed .po files
on:
workflow_dispatch:
# paths:
# - '**/*.po'
# branches:
# - 'dev'
jobs:
compile_mo:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
repository: wavelog/wavelog
ref: dev
fetch-depth: 2
- name: Set up gettext
run: sudo apt-get install -y gettext
- name: Compile .mo files from changed .po files
run: |
set -e
changed_po_files=$(git diff --name-only HEAD~1 HEAD | grep '\.po$' || true)
if [ -n "$changed_po_files" ]; then
for po in $changed_po_files; do
mo="${po%.po}.mo"
msgfmt -vv -o "$mo" "$po"
echo "Compiled $po to $mo"
done
else
echo "No .po files changed"
fi
- name: Commit changes
run: |
git config --global user.name "github-actions"
git config --global user.email "github-actions@github.com"
if [ -n "$(git status --porcelain)" ]; then
git add $(git ls-files --modified | grep '\.mo$')
git commit -m "Compiled .mo files (manually triggered)"
git push
else
echo "No changes to commit"
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -20,18 +20,28 @@ jobs:
- name: Set up gettext
run: sudo apt-get install -y gettext
- name: Run the po generator script
run: bash po_gen.sh
- name: Run the po generator script for the installer component aswell
run: bash install/po_gen_installer.sh
- name: Run all po_gen scripts
run: |
./po_gen.sh
./install/po_gen_installer.sh
- name: Commit changes
run: |
git config --global user.name "github-actions"
git config --global user.email "github-actions@github.com"
git add .
git commit -m "Run po_gen.sh script to update translation files"
git commit -m "po/mo updates"
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Command Weblate to perform a pull
env:
WEBLATE_TOKEN: ${{ secrets.WEBLATE_TOKEN }}
WEBLATE_URL: ${{ secrets.WEBLATE_URL }}
run: |
sleep 2
curl --silent \
-d operation=pull \
-H "Authorization: Token $WEBLATE_TOKEN" \
$WEBLATE_URL

5
install/po_gen_installer.sh Executable file → Normal file
View File

@@ -35,6 +35,11 @@ POT_COPYRIGHT_TEXT="Copyright (c) $YEAR Wavelog by DF2ET, DJ7NT, HB9HIL and LA8A
POT_LICENCE_TEXT="This file is distributed under the MIT licence."
FOLDERS="install"
echo "####################################################"
echo " "
echo "Performing the PO Generator Script for the Installer"
echo " "
# Find all PHP files and create a list in a temporary file
find $FOLDERS -name "*.php" > PHPFILESLIST

5
po_gen.sh Executable file → Normal file
View File

@@ -35,6 +35,11 @@ POT_COPYRIGHT_TEXT="Copyright (c) $YEAR Wavelog by DF2ET, DJ7NT, HB9HIL and LA8A
POT_LICENCE_TEXT="This file is distributed under the MIT licence."
FOLDERS="application assets src system"
echo "####################################################"
echo " "
echo "Performing the PO Generator Script for the Main Code"
echo " "
# Find all PHP files and create a list in a temporary file
find $FOLDERS -name "*.php" > PHPFILESLIST