-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy-zola-site
executable file
·80 lines (67 loc) · 1.21 KB
/
deploy-zola-site
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
#!/usr/bin/env bash
set -o errexit
set -o errtrace
set -o nounset
set -o pipefail
warn () {
if (( $# > 0 )); then
echo "${@}" 1>&2
fi
}
die () {
warn "${@}"
exit 1
}
notify () {
local code=$?
warn "✗ [FATAL] $(caller): ${BASH_COMMAND} (${code})"
}
trap notify ERR
display_help () {
cat << EOF
Synopsis:
${0##*/} [OPTION]...
Options:
-h, --help
show this help message and exit
-v, --version
output version information and exit
EOF
}
while (( $# > 0 )); do
case ${1} in
-h | --help)
display_help
shift
exit
;;
-v | --version)
echo v0.1.0
shift
exit
;;
--)
shift
break
;;
*)
break
;;
esac
done
if (( $# > 0 )); then
die "✗ argument parsing failed: unrecognizable argument ‘${1}’"
fi
clean_up () {
true
}
trap clean_up EXIT
PAGE=pages
git -C "${PAGE}" pull origin gh-pages
rm --force --recursive "${PAGE:?}/"*
zola build --output-dir "${PAGE}/public"
mv "${PAGE}/public/"* "${PAGE}"
rmdir "${PAGE}/public"
git -C "${PAGE}" add --all
git -C "${PAGE}" commit --message 'deploy zola site'
git -C "${PAGE}" push origin gh-pages