-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.sh
executable file
·46 lines (38 loc) · 1.06 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
#!/usr/bin/env bash
# deploy.sh: Script to deploy website to GitHub Pages
# Author: Nanda H Krishna (https://github.com/nandahkrishna)
# Get user confirmation to deploy
read -r -p "Deploy website? [y/N]: " choice
if [ "$choice" != "y" ]
then
echo "Aborted!"
exit 1
fi
# Check if there are uncommitted changes
if [ -n "$(git status --porcelain=v1 2>/dev/null)" ]
then
echo "Aborted: There are uncommitted changes!"
exit 1
fi
# Create or reset gh-pages
git checkout -B gh-pages
# Build site, delete and move files
bundle exec jekyll build
find . -maxdepth 1 ! -name "_site" ! -name "CNAME" ! -name ".gitignore" ! -name ".git" ! -name "." ! -name ".." -exec rm -rf {} \;
mv _site/* .
rm -rf _site/
# Show tree
read -r -p "Show tree? [y/N]: " choice
if [ "$choice" = "y" ]
then
tree
fi
# Add, commit and push to gh-pages
git add -fA
git commit --allow-empty -m "Deploy website ($(git log -1 --pretty=format:'%cd: %B' --date=short))"
git push -f -q origin gh-pages
# Checkout to master
git checkout master
# Display message and exit
echo "Deployed successfully!"
exit 0