forked from aepsilon/turing-machine-viz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update-gh-pages.sh
executable file
·36 lines (27 loc) · 944 Bytes
/
update-gh-pages.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
#!/bin/bash
# Updates the 'gh-pages' branch.
if grep -q Microsoft /proc/version; then
alias npm="cmd.exe /C npm"
fi
set -o errexit -o nounset
PREV_BRANCH="$(git symbolic-ref --short -q HEAD)" || {
>&2 echo 'Script must be started while on a branch.'
exit 1
}
if [ -n "$(git status --porcelain)" ]; then
>&2 echo 'Stash or commit changes before running this script.'
exit 1
fi
# Checkout gh-pages branch into temporary ./gh-pages/
mkdir gh-pages || { >&2 echo './gh-pages already exists. Operation cancelled.'; exit 1; }
git --work-tree=./gh-pages checkout gh-pages 1>/dev/null # suppress spurious diff
function restore() { rm -r ./gh-pages; git checkout -f "$PREV_BRANCH"; }
trap restore EXIT
# Generate and copy over
npm run prod
cp index.html gh-pages/ # CNAME
cp -r build gh-pages/
# Commit
echo Press enter to begin commit.; read
git --work-tree=./gh-pages add .
git --work-tree=./gh-pages commit -v -m 'Update gh-pages'