-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy path_helper.bash
executable file
·71 lines (56 loc) · 1.24 KB
/
_helper.bash
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
#!/bin/bash
# This is a deployment script
# Before one can use some initiation is required
# I found this is the best description that works for me
# https://gohugo.io/hosting-and-deployment/hosting-on-github/
unset origin
origin=$(dirname ${BASH_SOURCE[0]})
usage() {
echo "Usage: $origin [OPTIONS] "
echo "Options: "
echo ""
echo " worktree: add gh-pages to git worktree"
echo " deploy: deploy to gh-pages"
echo ""
echo ""
}
# Step 1
# git checkout --orphan gh-pages
# git reset --hard
# git commit --allow-empty -m "Initializing gh-pages branch"
# git push origin gh-pages
# git checkout master
echo "MSG: starting deployment $(date)"
add_worktree() {
echo "MSG: Adding new worktree"
rm -rf _book
git worktree add -B gh-pages _book origin/gh-pages
}
deploy_book() {
book_dir=${1}
cd ${book_dir}
build_number=$(git --no-pager log --format=%B -n 1 | sed '/^$/d' | cut -f2 -d" ")
build_number=$((${build_number} + 1))
echo "MSG: Build number ${build_number}"
git add --all
git commit -m "build ${build_number}"
cd ..
git push origin gh-pages
}
case "$1" in
help|-h|--help)
usage
exit
;;
worktree)
add_worktree
exit
;;
deploy)
deploy_book _book
exit
;;
*)
usage
exit
esac