-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.sh
executable file
·56 lines (47 loc) · 1.19 KB
/
update.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
#!/usr/bin/env bash
# Change certain files, commit, and push.
# Helpful for testing the Mobu github integration.
set -euo pipefail
# Generate a random string
# https://unix.stackexchange.com/a/230676
sentinel=$(
tr -dc A-Za-z0-9 </dev/urandom | head -c 13
echo
)
# Leave some notebooks unchanged
files="not-a-notebook.txt simple_notebook_1.ipynb somedir/simple_notebook_2.ipynb"
exception_file="exceptions/exception_notebook_1.ipynb"
pr_branch="dfuchs-test-pr"
update_exception=false
# Parse commandline args
for arg in "${@}"; do
if [ "${arg}" = "-e" ]; then
update_exception=true
elif [ "${arg}" = "-m" ]; then
pr_branch=main
fi
done
echo "Checking out branch: $pr_branch"
git checkout $pr_branch
for file in $files; do
sed -i "s/:::.*:::/:::$sentinel:::/g" "$file"
done
# Conditionally update the notebook that intentionally blows up
if $update_exception; then
echo "Changing intentionally bad notebook"
sed -i "s/:::.*:::/:::$sentinel:::/g" $exception_file
cat <<- 'END' > mobu.yaml
exclude_dirs:
- some-dir
END
else
cat <<- 'END' > mobu.yaml
exclude_dirs:
- some-dir
- exceptions
END
fi
git add .
git commit -m "refresh $sentinel"
git push
echo "Sentinel: $sentinel"