-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgh-pages.sh
More file actions
executable file
·33 lines (29 loc) · 894 Bytes
/
Copy pathgh-pages.sh
File metadata and controls
executable file
·33 lines (29 loc) · 894 Bytes
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
#!/usr/bin/env bash
# pre-commit hook using ghp-import to push HTML to Github Pages.
# Assumes:
# HTML exists in docs folder.
# ghp-import in PATH, e.g., `python -m pip install ghp-import`.
# `git config ghppages.pathhtml <absolute path>/docs`. Defaults to
# "$GIT_WORK_TREE/docs".
# `git config ghppages.push true`. Otherwise skip publishing.
if git config --get-colorbool color.interactive
then
# See https://github.com/vimwiki/vimwiki/blob/master/doc/logo.svg
say_prefix='\e[90mghp\e[92m|\e[37mimport\e[0m'
else
say_prefix='ghp-import'
fi
say () {
printf '%b: %s' "$say_prefix" "$*"
}
say_done () {
printf 'done.\n'
}
# Update gh-pages
if test "$(git config --bool ghppages.push || echo false)" = true
then
pathhtml=$(git config ghppages.pathhtml || echo "$GIT_WORK_TREE/docs")
say 'Pushing html to gh-pages...'
ghp-import -n -o -p -f "$pathhtml"
say_done
fi