-
Notifications
You must be signed in to change notification settings - Fork 5
/
.travis-run.sh
executable file
·68 lines (54 loc) · 2.25 KB
/
.travis-run.sh
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
#!/bin/bash
set -x
MAIN_LANG=es
# If Pull Request merge or new commit, and change in main SLA file, extract JSON and commit it
git diff-tree --no-commit-id --name-only -r HEAD | grep \.es\.sla$ | while read sla_file
do
if [ -f $sla_file ]; then
filename=`basename $sla_file .sla`.json
filedirname=`dirname $sla_file`
docker run -t --rm -v `pwd`:/work nicopace/sla-to-translatewiki-json /work/$sla_file -e -o /work/$filedirname/$filename
fi
done
# If JSON change, merge SLA with JSON
git diff-tree --no-commit-id --name-only -r HEAD | grep \.json$ | while read json_file
do
if [ -f $json_file ]; then
json_filename=$json_file
filename="${json_filename%.*}"
language="${filename##*.}"
if [ "$MAIN_LANG" != "$language" ]; then
filename="${filename%.*}" # because it has two extensions
destiny_sla_filename=$filename.$language.sla
if [ ! -f $destiny_sla_filename ]; then
# First time doing it, copy resources file
cp $filename.$MAIN_LANG.sla $destiny_sla_filename
dest_dir=`dirname $filename`
cp -r $dest_dir/assets-$MAIN_LANG $dest_dir/assets-$language
sed -i "s/assets-$MAIN_LANG/assets-$language/" $destiny_sla_filename
fi
filedirname=`dirname $json_filename`
docker run -t --rm -v `pwd`:/work nicopace/sla-to-translatewiki-json /work/$destiny_sla_filename -m /work/$json_filename -o /work/$destiny_sla_filename
fi
fi
done
# If SLA or Asset file or JSON change, generate PDF
git diff-tree --no-commit-id --name-only -r HEAD | grep \.sla$ | while read sla_file # TODO implement '.sla$\|asset\|.json$' processing
do
if [ -f $sla_file ]; then
filename="${sla_filename%.*}"
language="${filename##*.}"
if [ "$MAIN_LANG" != "$language" ]; then
filename="${filename%.*}" # because it has two extensions
docker run -t --rm -v `pwd`:/work nicopace/sla-to-pdf /work/$sla_file
fi
fi
done
env
git remote add httporigin https://${GH_TOKEN}@github.com/librerouterorg/docs.git > /dev/null 2>&1
git stash
git checkout master
git stash apply
git add .
git commit -m 'Automated updates.'
git push httporigin master