-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.sh
executable file
·49 lines (36 loc) · 1.01 KB
/
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
48
49
#!/usr/bin/env sh
# Run this script to deploy the app to Github Pages.
# Exit if any subcommand fails.
set -e
echo "Started deploying"
cd $(dirname "$0") || exit
if [ -n "$(git status --porcelain)" ]; then
echo "working directory not clean, exiting."
exit 1
fi
if ! git diff --exit-code > /dev/null; then
echo "working directory not clean, exiting."
exit 1
fi
echo "switching to gh-pages branch..."
if git branch | grep -q gh-pages
then
git branch -D gh-pages &> /dev/null
fi
git checkout -b gh-pages &> /dev/null
trap "git checkout - &> /dev/null" EXIT
# Build site.
echo "building site..."
./build.sh
# Delete and move files.
find . -maxdepth 1 ! -name 'dist' ! -name '.git' ! -name '.gitignore' -exec rm -rf {} \;
mv dist/* .
rm -R dist/
# Push to gh-pages.
echo "committing compiled site..."
git add -A > /dev/null
git commit --allow-empty -m "$(git log -1 --pretty=%B)" > /dev/null
echo "pushing compiled site..."
git push -f -q origin gh-pages > /dev/null
echo "Deployed Successfully! <3"
exit 0