-
Notifications
You must be signed in to change notification settings - Fork 2
/
deploy.sh
executable file
·48 lines (36 loc) · 1017 Bytes
/
deploy.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
#!/usr/bin/env bash
# if -f supplied, will force-recreate gh-pages branch
set -e
set -x
# Ensure that the CWD is set to script's location
cd "${0%/*}"
CWD=$(pwd)
cd ..
#######
echo "Pulling / pushing ... (should pull nothing)"
git pull
git push
echo "Assembling the site..."
./scripts/build.py
echo "Pushing gh-pages..."
# https://stackoverflow.com/a/40178818/1644554
# https://unix.stackexchange.com/a/155077/219051
if output=$(git status --porcelain) && [ -z "$output" ]
then
if [ $# -eq 1 ] && [ $1 = "-f" ]
then
git push origin --delete gh-pages
fi
# changed the next line to make sure it works for BSD, GNU (works for Mac and Linux)
sed -i.bak '/dist/d' ./.gitignore
# delete the newly created back up file
rm ./.gitignore.bak
git add .
git commit -m "Edit .gitignore to publish"
git push origin `git subtree split --prefix dist master`:gh-pages --force
git reset HEAD~
git checkout .gitignore
echo "Done!"
else
echo "Need clean working directory to publish -- WILL NOT PUBLISH!!"
fi