-
Notifications
You must be signed in to change notification settings - Fork 0
/
render.sh
executable file
·59 lines (44 loc) · 1.1 KB
/
render.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
#!/usr/bin/env bash
if [ -z "$1" ]; then
echo "Usage: "
echo " Rendering one course: $0 <code>"
echo " Rendering all courses: $0 all"
exit 1
fi
code="$1"
if [ "$code" = "all" ]; then
for folder in src/G*/; do
folder_name=$(basename "$folder")
"$0" "$folder_name"
done
exit 0
fi
src_folder="src/$code"
if [ ! -d "$src_folder" ] && [ "$code" != "all" ]; then
echo "Error: Folder '$code' not found in 'src' directory."
echo "Usage: "
echo " Rendering one course: $0 <code>"
echo " Rendering all courses: $0 all"
exit 1
fi
set -e
docker run --rm -v "$(pwd)/src:/app" -v "$(pwd)/out:/out" gispo/bookdown:latest /app/run.sh $code
if [ ! -d "docs" ]; then
mkdir docs
fi
if [ "$WORKFLOW" = true ]; then
if [ -d "docs/$code" ]; then
rm -rf "docs/$code"
fi
mv "out/$code" "docs/$code"
rm -R out
test -f "docs/$code/index.html"
fi
if [ "$ARTIFACT" = true ]; then
if [ ! -d "artifact" ]; then
mkdir artifact
fi
mv "out/$code" "artifact/$code"
rm -R out
test -f "artifact/$code/index.html"
fi