-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpublish.sh
executable file
·65 lines (51 loc) · 1.89 KB
/
publish.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
#!/bin/bash
set -e
shopt -s nullglob # Use empty array if globbing pails
shopt -s nocaseglob # Ignore case in globbing
shopt -s extglob # Extended globbing
function update_hw_modules() {
echo "Looking for graded homework notebooks"
homework_files=(./textbook/notebooks/homework/HW*GR.ipynb)
submodule_dirs=(./homework-modules/*)
for file in "${homework_files[@]}"
do
# Extract file base name and remove dashes and underscores
fname=$(basename $file .ipynb)
fname=${fname//_/}
fname=${fname//-/}
# Look for matching directory/submodule
for dir in "${submodule_dirs[@]}"
do
dname=$(basename $dir)
dname=${dname##python-camp}; # Remove directory prefix
dname=${dname//-/}
dname=${dname//_/}
if [[ "$fname" =~ "$dname" ]]; then
echo "Copying ${file} to ${dir}/"
cp ${file} ${dir}/
echo "Committing and updating"
git -C ${dir} add $(basename $file)
git -C ${dir} diff-index --quiet HEAD || git -C ${dir} commit -am "Change to $(basename $file)commited from main repo"
git -C ${dir} push origin main
fi
done
done
}
function main() {
echo "Building Parsons Problems"
python ./course_utils/parsons_builder.py
echo "Building book from scratch"
jupyter-book clean textbook/
jupyter-book build textbook/
echo "Cleaning up notebook formatting"
python ./course_utils/postprocessing.py
echo "Publishing to GH pages"
ghp-import -n -p -f textbook/_build/html
echo "Updating submodules"
update_hw_modules
echo "Committing post-processing changes"
# Add any new Parsons Problems created in step one
git add textbook/parsons-assets/parsons-problems/html
git commit -a -m "Committing submodule changes"
}
main