Skip to content

Commit fc1fedb

Browse files
authored
Add only .po for changed .rst files on pull-translations (#2449)
When translation is ready Crowdin tends to download all the translated .po files. It can be annoying when the Crowdin branch has more changed files then it needed for the current PR. It forces the author to clean PR manually. The fixed pull-translation workflow contains a filter which allows to add only corresponding .po files to the changed .rst files in the current branch. Closes #2434
1 parent cb9256d commit fc1fedb

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

.github/workflows/pull-translation.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ name: Pull translations
22

33
on:
44
workflow_dispatch:
5+
inputs:
6+
commit_po_for_unchanged_rst:
7+
description: 'Update translations for unchanged .rst'
8+
default: "false"
9+
required: True
510
branches:
611
- '!latest'
712

@@ -14,6 +19,7 @@ jobs:
1419
- uses: actions/checkout@v2
1520
with:
1621
token: "${{ secrets.TARANTOOLBOT_TOKEN }}"
22+
fetch-depth: 2
1723

1824
- name: Set branch name from source branch
1925
run: echo "BRANCH_NAME=${GITHUB_REF##*/}" >> $GITHUB_ENV
@@ -40,8 +46,16 @@ jobs:
4046
- name: Cleanup translation files
4147
run: make cleanup-po
4248

49+
- name: Set $CHANGED_POS for changed .rst files only
50+
run: echo "CHANGED_POS=$(echo "$(git diff --name-only | grep .po | sed "s/.po//" | sed "s/locale\/ru\/LC_MESSAGES\///")" | awk -v rst="$(git diff-tree --no-commit-id --name-only -r HEAD | grep .rst | tr "\n" " ")" 'rst ~ $0{ print "locale/ru/LC_MESSAGES/"$0".po" }')" >> $GITHUB_ENV
51+
if: ${{github.event.inputs.commit_po_for_unchanged_rst == 'false'}}
52+
53+
- name: Set $CHANGED_POS for all .rst files
54+
run: echo "CHANGED_POS=.po" >> $GITHUB_ENV
55+
if: ${{github.event.inputs.commit_po_for_unchanged_rst != 'false'}}
56+
4357
- name: Commit translation files
4458
uses: stefanzweifel/git-auto-commit-action@v4.1.2
4559
with:
4660
commit_message: "Update translations"
47-
file_pattern: "*.po"
61+
file_pattern: "${{ env.CHANGED_POS }}"

0 commit comments

Comments
 (0)