-
Notifications
You must be signed in to change notification settings - Fork 1
/
push_to_autobuild.sh
76 lines (65 loc) · 2.5 KB
/
push_to_autobuild.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
69
70
71
72
73
74
75
#!/bin/bash
# exit when any command fails
set -e
tmp=$(mktemp -d -d ./input/_examples) && echo "\$tmp = $tmp"
function finish {
# Your cleanup code here
echo '=== clean up - rename the input/_fsh folder to input/fsh ==='
mv input/_fsh input/fsh && echo 'done!'
echo '====clean up - copy tmp files to examples folder to restore meta elements ===='
cp -f $tmp/*.json ./input/examples && echo 'done!'
echo "====clean up - remove $tmp ===="
rm -rf $tmp && echo 'removed $tmp from docs directory'
}
trap finish EXIT
trap finsh ERR
while getopts sm option
do
case "${option}"
in
s) SUSHI=true;;
m) NO_META=true;;
esac
done
echo "================================================================="
echo "=== commit and load to github for autopublisher ==="
echo "-s parameter for enabling sushi in autopublisher = $SUSHI (default is false)"
echo "-m parameter for enabling meta in autopublisher = $NO_META (default is false)"
echo "================================================================="
echo "================================================================="
echo "=== remove all mkdown from docs directory ==="
echo "================================================================="
ls docs/*.md && rm docs/*.md
ls docs/*.md && echo 'done!'
if ! [[ $SUSHI ]]; then
echo "================================================================="
echo "=== rename the 'input/fsh' folder to 'input/_fsh' ==="
echo "================================================================="
[[ -d input/fsh ]] && mv input/fsh input/_fsh
fi
if [[ $NO_META ]]; then
echo "================================================================="
echo "===remove the meta element from all the examples==="
echo "================================================================="
cp ./input/examples/*.json $tmp
for file in $tmp/*.json
do
jq 'del(.meta)' < $file > ./input/examples/$(basename $file)
done
fi
echo "================================================================="
echo "=== hit 'a' to commit and push all including untracked files ===="
echo "=== else 'c' for only tracked file or ctrl-c to exit ==="
echo "================================================================="
read var1
echo "================================================================="
echo "==================== you typed '$var1' ============================"
echo "================================================================="
if [ $var1 == "c" ]; then
git commit -a
git push
elif [ $var1 == "a" ]; then
git add .
git commit
git push
fi