blob: 2148d2b2d49567f79545c8f1447e0784da400d73 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
name: Translation Updates
on:
schedule:
- cron: "0 2 * * 6"
jobs:
build:
runs-on: ubuntu-latest
services:
mysql:
image: mysql:5.7
env:
MYSQL_ALLOW_EMPTY_PASSWORD: true
MYSQL_ROOT_PASSWORD: ""
MYSQL_DATABASE: piwik_tests
ports:
- 3306/tcp
steps:
- uses: shivammathur/setup-php@v1
with:
php-version: '7.3'
- uses: actions/checkout@v2
with:
ref: '4.x-dev'
lfs: false
- name: Prepare branches
run: |
cat <<- EOF > $HOME/.netrc
machine github.com
login $GITHUB_ACTOR
password $GITHUB_TOKEN
machine api.github.com
login $GITHUB_ACTOR
password $GITHUB_TOKEN
EOF
chmod 600 $HOME/.netrc
git config --global user.email "$GITHUB_ACTOR@users.noreply.github.com"
git config --global user.name "$GITHUB_ACTOR"
git remote add upstream https://github.com/matomo-org/matomo.git
git push origin --delete translationupdates || true
git branch -D translationupdates || true
git fetch upstream 4.x-dev
git checkout -f upstream/4.x-dev
git branch translationupdates
git checkout -f translationupdates
- name: Checkout submodules
run: git submodule update --init --force
- name: Install Dependencies
run: composer install --prefer-dist
- name: Initialize Matomo
run: |
cp ./tests/travis/config.ini.travis.php ./config/config.ini.php
./console development:enable
- name: Sync translations
run: ./console translations:update --username ${{ secrets.TransifexUsername }} --password ${{ secrets.TransifexPassword }} --force --no-interaction
- name: Check for changes
id: changes
run: |
IFS=$'\n'
changes=( $(git diff --numstat | grep -E '([0-9]+)\s+([0-9]+)\s+[a-zA-Z\/]*lang\/([a-z]{2,3}(?:-[a-z]{2,3})?)\.json' ) )
unset IFS
# abort here if no change available
if [[ ${#changes[@]} -eq 0 ]]
then
exit 0
fi
git add lang/
git add "*.json"
declare -i totaladditions=0
declare -A additionsByLang
for (( i=0; i < ${#changes[@]}; i++ )); do
line=( ${changes[$i]} )
additions=${line[0]}
if [[ ${line[0]} = "0" ]]
then
continue;
fi
file=${line[2]}
lang=$( echo ${line[2]} | grep -oE '([a-z]{2,3}(?:-[a-z]{2,3})?)\.json' | cut -d'.' -f 1 )
totaladditions=$(( totaladditions + additions ))
additionsByLang[$lang]=$(( additionsByLang[$lang] + additions ))
done
title="Updated $totaladditions strings in ${#additionsByLang[@]} languages (${!additionsByLang[@]})"
languageInfo=( $( ./console translations:languageinfo ) )
for i in ${!additionsByLang[@]}; do
for j in ${languageInfo[@]}; do
if [[ "$j" == "$i|"* ]];
then
IFS=$'\n'
info=( $( echo "$j" | tr "|" "\n" ) )
unset IFS
break
fi
done
message="$message- Updated ${info[1]} (${additionsByLang[$i]} changes / ${info[2]} translated)\n"
done
message="$message\n\nHelp us translate Matomo in your language!\nSignup at https://www.transifex.com/matomo/matomo/\nIf you have any questions, get in touch with us at translations@matomo.org"
echo $title
echo $message
echo ::set-output name=title::$title
echo ::set-output name=message::$message
shell: bash
- name: Push changes
run: |
git commit -m "language update"
git push --set-upstream origin translationupdates
- name: Create PR
run: |
curl \
--request POST \
--header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
--header 'content-type: application/json' \
--data '{
"title":"[automatic translation update] ${{ steps.changes.outputs.title }}",
"body":"${{ steps.changes.outputs.message }}",
"head":"translationupdates",
"base":"4.x-dev"
}' \
--url https://api.github.com/repos/${GITHUB_REPOSITORY}/pulls
shell: bash
if: steps.changes.outputs.title
|