From d76814fdbbcee923987b60adeb4221bfdc7bd87c Mon Sep 17 00:00:00 2001 From: past-due <30942300+past-due@users.noreply.github.com> Date: Fri, 19 Apr 2024 22:25:42 -0400 Subject: [PATCH] [GitHub Actions] Tweak Crowdin workflows [ci skip] --- .ci/githubactions/crowdin_download_diff.sh | 12 ++++++++++++ .github/workflows/crowdin_download_translations.yml | 9 +++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) create mode 100755 .ci/githubactions/crowdin_download_diff.sh diff --git a/.ci/githubactions/crowdin_download_diff.sh b/.ci/githubactions/crowdin_download_diff.sh new file mode 100755 index 00000000000..73e1e8f16a7 --- /dev/null +++ b/.ci/githubactions/crowdin_download_diff.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +# Output the filenames that have actual modifications, ignoring certain .po file header lines +# Note: Requires GNU Diffutils +diff --brief --recursive --unified=1 --new-file \ + --ignore-matching-lines='^"POT-Creation-Date: .*"' \ + --ignore-matching-lines='^"PO-Revision-Date: .*"' \ + --ignore-matching-lines='^"Last-Translator: .*"' \ + "$@" \ + | cut -d' ' -f 2 | sed "s#$1*##" + +exit 0 diff --git a/.github/workflows/crowdin_download_translations.yml b/.github/workflows/crowdin_download_translations.yml index f2823616564..51fd1b81d9d 100644 --- a/.github/workflows/crowdin_download_translations.yml +++ b/.github/workflows/crowdin_download_translations.yml @@ -65,7 +65,13 @@ jobs: run: | git config user.name "github-actions[bot]" git config user.email "<41898282+github-actions[bot]@users.noreply.github.com>" - git add -A + # Add modified files (ignoring po header modifications): + git difftool --dir-diff --extcmd=.ci/githubactions/crowdin_download_diff.sh | xargs -0 git add + # Add untracked (new) files: + git ls-files --others --exclude-standard | xargs -0 git add + echo "Debug output:" + git status + echo "Commit changes:" git commit -m "New Crowdin translations" || { echo "PROCESS_PR=false" >> $GITHUB_OUTPUT && exit 0; } echo "Pushing changes to l10n_master branch" git push -f origin master:l10n_master @@ -74,7 +80,6 @@ jobs: - name: Create Pull Request to update translations (if needed) if: success() && (github.repository == 'Warzone2100/warzone2100') && (steps.pushupdates.outputs.PROCESS_PR == 'true') id: cpr - working-directory: '${{ github.workspace }}/master' env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} GH_REPO: ${{ github.repository }}