File tree 3 files changed +59
-4
lines changed
3 files changed +59
-4
lines changed Original file line number Diff line number Diff line change 19
19
- uses : actions/checkout@v2
20
20
with :
21
21
token : " ${{ secrets.TARANTOOLBOT_TOKEN }}"
22
- fetch-depth : 2
22
+ fetch-depth : 0
23
23
24
24
- name : Set branch name from source branch
25
25
run : echo "BRANCH_NAME=${GITHUB_REF##*/}" >> $GITHUB_ENV
@@ -47,15 +47,20 @@ jobs:
47
47
run : make cleanup-po
48
48
49
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
50
+ shell : bash
51
+ run : |
52
+ set -x
53
+ . list_changed_po.sh
54
+ if [ -z "${CHANGED_POS}" ]; then exit 1; fi
55
+ echo "CHANGED_POS=${CHANGED_POS}" >> $GITHUB_ENV
51
56
if : ${{github.event.inputs.commit_po_for_unchanged_rst == 'false'}}
52
57
53
58
- name : Set $CHANGED_POS for all .rst files
54
- run : echo "CHANGED_POS=.po" >> $GITHUB_ENV
59
+ run : echo "CHANGED_POS=* .po" >> $GITHUB_ENV
55
60
if : ${{github.event.inputs.commit_po_for_unchanged_rst != 'false'}}
56
61
57
62
- name : Commit translation files
58
- uses : stefanzweifel/git-auto-commit-action@v4.1.2
63
+ uses : stefanzweifel/git-auto-commit-action@v4.12.0
59
64
with :
60
65
commit_message : " Update translations"
61
66
file_pattern : " ${{ env.CHANGED_POS }}"
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ locale/**/*.mo
7
7
_ * _build /
8
8
deploy_key
9
9
.venv
10
+ venv
10
11
output
11
12
* .pyc
12
13
_theme /tarantool /static /design.css.map
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+
3
+ # The root directory of .po files
4
+ locale_path=locale/ru/LC_MESSAGES/
5
+
6
+ ESCAPED_REPLACE=$( printf ' %s\n' " $locale_path " | sed -e ' s/[\/&]/\\&/g' )
7
+
8
+ unset CHANGED_POS
9
+
10
+ get_git_diff () {
11
+ echo " $( git diff --name-only ; git ls-files . --exclude-standard --others) "
12
+ }
13
+
14
+ get_changed_po () {
15
+ changed_po_files=" $( get_git_diff | grep \\ .po) "
16
+ if [ -z " ${changed_po_files} " ]; then
17
+ echo " ERROR: changed .po files not found"
18
+ return
19
+ fi
20
+ echo " $( get_git_diff | grep \\ .po) "
21
+ }
22
+
23
+ get_po_base_names () {
24
+ echo " $( get_changed_po | sed " s/.po//" | sed " s/$ESCAPED_REPLACE //" ) "
25
+ }
26
+
27
+ get_rst_from_diff () {
28
+ echo $( git diff-tree --no-commit-id --name-only -r HEAD..origin/latest | grep .rst)
29
+ }
30
+
31
+ echo " * Getting changed .po files:"
32
+ changed_po=" $( get_changed_po) "
33
+ echo $changed_po
34
+
35
+ echo
36
+ echo " * Getting a list of .rst files to compare with changed .po files:"
37
+ rst_from_diff=$( get_rst_from_diff)
38
+ echo $rst_from_diff
39
+
40
+ echo
41
+ echo " * Filtering corresponding .po files to the changed .rst in the closest commit:"
42
+ po_files_to_commit=$( get_po_base_names | awk -v rst=" $rst_from_diff " -v locale_path=$locale_path ' rst ~ $0{ printf locale_path; print ""$0".po" }' )
43
+ echo $po_files_to_commit
44
+
45
+ if [ -n " ${po_files_to_commit} " ]; then
46
+ export CHANGED_POS=" $( echo $po_files_to_commit | tr " \n" " " ) "
47
+ else
48
+ echo " ERROR: could not find any matched po file to commit"
49
+ fi
You can’t perform that action at this time.
0 commit comments