Skip to content

git-pot

git-pot #24768

Workflow file for this run

# CI workflows for po/git.pot: generate "po/git.pot" from git.git
# repository and show diffs on a daily basis.
#
# NOTE: must define the secret "PUSH_TOKEN" for this repository on GitHub.
#
name: git-pot
on:
# Schedule only works when the pipeline.yaml file is defined in default
# branch, i.e. the "main" branch.
schedule:
- cron: '51 */1 * * *'
# We can also trigger using manual event by an external schedule, when
# the schedule not works for some reasons, such as: the CI pipeline is
# not defined in the default branch.
workflow_dispatch:
push:
branches:
- main
jobs:
git-pot:
strategy:
matrix:
# Check the following branches of the git.git repository.
branch: [master, next, seen]
runs-on: ubuntu-latest
env:
AUTHOR_NAME: GotGit
AUTHOR_EMAIL: [email protected]
LOGIN_NAME: togtig
steps:
- name: skip if the commit was already tested
id: skip-if-redundant
run: |
git -c protocol.version=2 ls-remote https://github.com/git/git.git \
refs/heads/${{ matrix.branch }} >footprint.remote &&
(
wget -O footprint.last \
https://raw.githubusercontent.com/${{ github.repository }}/pot/${{ matrix.branch }}/.latest-footprint ||
true
) &&
if diff footprint.remote footprint.last
then
echo "status=skip" >> $GITHUB_OUTPUT
else
echo "status=no" >> $GITHUB_OUTPUT
fi
- name: clone pot/${{ matrix.branch }} branch of current repository
if: steps.skip-if-redundant.outputs.status != 'skip'
run: |
( git -c protocol.version=2 clone \
--depth 1 \
--single-branch --branch pot/${{ matrix.branch }} \
https://github.com/${{ github.repository }} pot-changes ||
( git init --initial-branch "pot/${{ matrix.branch }}" pot-changes &&
git -C pot-changes remote add origin \
https://github.com/${{ github.repository }}
)
) &&
cd pot-changes &&
git config user.name "${{ env.AUTHOR_NAME }}" &&
git config user.email "${{ env.AUTHOR_EMAIL }}" &&
mkdir -p po &&
if test ! -f README.md
then
echo "[![Build status](https://github.com/${{ github.repository }}/actions/workflows/git-pot.yml/badge.svg)](https://github.com/${{ github.repository }}/actions/workflows/git-pot.yml)" >README.md &&
echo >>README.md &&
echo "# Changes of \"po/git.pot\" in the ${{ matrix.branch }} branch" >>README.md &&
echo >>README.md &&
echo "This branch will be updated regularly by a robot. See:" >>README.md &&
echo >>README.md &&
echo " - \`po/git.pot\`: generated from the corresponding branch of the git.git repository." >>README.md &&
echo " - \`<YYYY-mm-dd>.diff\`: changes of \"po/git.pot\" since last update." >>README.md &&
git add README.md &&
git commit -m "doc: add README"
fi
- name: install dependencies
if: steps.skip-if-redundant.outputs.status != 'skip'
run: |
if ! type xgettext
then
sudo apt-get update -q &&
sudo apt-get install -q -y gettext
fi
- name: clone git repository
if: steps.skip-if-redundant.outputs.status != 'skip'
run: |
git -c protocol.version=2 clone \
--depth 1 \
--single-branch --branch ${{ matrix.branch }} \
https://github.com/git/git.git git
- name: generate po/git.pot
if: steps.skip-if-redundant.outputs.status != 'skip'
run: |
make -C git pot &&
if test ! -f pot-changes/po/git.pot; then
cp git/po/git.pot pot-changes/po/git.pot &&
cd pot-changes &&
git add po/git.pot &&
git commit -m "Initialize po/git.pot"
fi
- uses: actions/setup-go@v5
if: steps.skip-if-redundant.outputs.status != 'skip'
with:
go-version: '^1.18'
cache: false
- name: Install git-po-helper
if: steps.skip-if-redundant.outputs.status != 'skip'
run: go install github.com/git-l10n/git-po-helper@main
- name: upload changes and report
if: steps.skip-if-redundant.outputs.status != 'skip'
run: |
report_msg="" &&
cd pot-changes &&
mv ../footprint.remote .latest-footprint &&
mkdir -p po/ &&
if test -f po/git.pot
then
msgcat --no-location --sort-output --no-wrap po/git.pot |
sed -e '1,/^$/d' >po/git.pot.old
else
touch po/git.pot.old
fi &&
cp ../git/po/git.pot po/git.pot &&
msgcat --no-location --sort-output --no-wrap po/git.pot |
sed -e '1,/^$/d' >po/git.pot.new &&
date=$(date "+%Y-%m-%d") &&
diff=${date}.diff &&
if ! diff -q po/git.pot.old po/git.pot.new
then
printf "\n\n#################### $(date -R) ####################\n\n" >>"$diff"
( diff -u po/git.pot.old po/git.pot.new >>"$diff" || true ) &&
( cd ../git && git-po-helper check-pot 2>&1 || true ) >check-pot.txt &&
if test -s check-pot.txt
then
printf -- "\n\n-------------------- git-po-helper check-pot --------------------\n\n" >>"$diff" &&
cat check-pot.txt >>"$diff"
fi &&
git add po/git.pot "$diff" .latest-footprint &&
git commit -m "l10n: ${{ matrix.branch }}: changes of git.pot in $diff" &&
report_msg="** changes of 'po/git.pot' is reported in $diff **"
else
echo >&2 "** po/git.pot is not changed **"
git add .latest-footprint &&
( git commit -m "no l10n changes on $date" || true ) &&
report_msg="** nothing changed in 'po/git.pot' on $date **"
fi &&
git push \
https://${{ env.LOGIN_NAME }}:${{ secrets.PUSH_TOKEN }}@github.com/${{ github.repository }} \
HEAD &&
printf >&2 "\n$report_msg\n"