forked from nyuvis/patient-viz
-
Notifications
You must be signed in to change notification settings - Fork 1
/
full_deploy.sh
executable file
·125 lines (107 loc) · 2.44 KB
/
full_deploy.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
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
#!/bin/bash
# @author Joschi <josua.krause@gmail.com>
# created 2015-02-27 10:39
master="master"
web="gh-pages"
origin="origin"
USAGE="Usage: $0 -h [--full]"
usage() {
echo $USAGE
echo "-h: print help"
echo "--full: whether to update the patient files"
exit 1
}
full=
while [ $# -gt 0 ]; do
case "$1" in
-h)
usage ;;
--full)
full=1
;;
*)
echo "illegal option -- $1"
usage ;;
esac
shift
done
if [[ $# -gt 1 ]]; then
echo "illegal option -- $1"
usage
fi
do_restore=
restore() {
if [ ! -z "${do_restore}" ] && [ -f "json.zip" ]; then
echo "restore patient files"
if [ -d "json" ]; then
rm -r "json"
fi
do_restore=
unzip "json.zip"
test_fail $?
rm "json.zip"
fi
}
test_fail() {
if [ $1 -ne 0 ]; then
echo "deploying failed!"
restore
exit 1
fi
}
prompt() {
abort=
text=$1
while true; do
read -p "${text} [y]es [n]o: " yn
case $yn in
[Yy]* )
break
;;
[Nn]* )
abort=1
break
;;
esac
done
if [ ! -z "${abort}" ]; then
return 1
fi
return 0
}
msg="Do you really want to publish to ${origin}/${web}"
if [ ! -z "${full}" ]; then
msg="${msg} and update patient files"
fi
prompt "${msg}?"
if [ $? -ne 0 ]; then
exit 0
fi
if [ -z "${full}" ] && [ -z `git branch -r --no-merged "${web}" | grep "${master}"` ]; then
echo "gh-pages already up to date"
exit 1
fi
onmaster=`git branch | grep "* ${master}"`
if [ -z "${onmaster}" ]; then
echo "not on ${master}"
exit 1
fi
if [ -d "json" && -f patients.txt ]; then
echo "save current patient files"
zip -r "json.zip" "patients.txt" "json"
test_fail $?
fi
do_restore=1
git checkout "${web}" && git merge --no-ff "${master}" --no-commit
test_fail $?
if [ ! -z "${full}" ]; then
./setup.sh --clean --burst --default --convert "9F6F484429DDCC04 AE056C5933AFED18 298C80CC2F7CEDC4 EB704BFBAB4E2B86 B7ECA3897A4AD00D A9BD9D012E87A360 4EF051B883DE5192 998093F33FE2D940 CDBF9E622DEE5B07 AEF023C2029F05BC"
test_fail $?
git add -f json/9F6F484429DDCC04.json json/AE056C5933AFED18.json json/298C80CC2F7CEDC4.json json/EB704BFBAB4E2B86.json json/B7ECA3897A4AD00D.json json/A9BD9D012E87A360.json json/4EF051B883DE5192.json json/998093F33FE2D940.json json/CDBF9E622DEE5B07.json json/AEF023C2029F05BC.json json/dictionary.json patients.txt
test_fail $?
fi
git commit
test_fail $?
git push "${origin}" "${web}" && git checkout "${master}"
test_fail $?
restore