forked from KrauseFx/krausefx.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.sh
executable file
·45 lines (34 loc) · 1.53 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
# Partly taken from https://medium.com/@nielsenramon/automated-deployment-of-jekyll-projects-to-github-pages-using-kickster-and-circle-ci-6ccc0b6cb872#.qxsy1xf1m
# Partly taken from https://github.com/fastlane/docs
# Exit if any subcommand fails.
set -e
echo "Starting deploy to https://krausefx.com"
# Build the docs page locally
export JEKYLL_ENV="production"
bundle exec jekyll build
# Bots need names too
git config --global user.email "[email protected]"
git config --global user.name "KrauseFx-Bot"
# Delete old directories (if any)
rm -rf "/tmp/krausefx.com"
# Copy the generated website to the temporary directory
cp -R "_site/" "/tmp/krausefx.com"
# Check out gh-pages and clear all files
git reset --hard HEAD # we don't want the `git checkout` to cause issues (e.g. https://circleci.com/gh/fastlane/docs/730)
git checkout -b gh-pages
git remote add upstream "https://[email protected]/KrauseFx/krausefx.com.git"
git pull
rm -rf *
# Copy the finished HTML pages to the current directory
cp -R /tmp/krausefx.com/* .
# We need a CNAME file for GitHub
echo "krausefx.com" > "CNAME"
# Commit all the changes and push it to the remote
git add -A
git commit -m "Deployed with $(jekyll -v)"
git push upstream gh-pages --force # force needed, as travis somehow can't re-use branches
# Post a Slack message
git checkout master
echo "Deployed successfully, check out https://krausefx.com"
echo "If you're running this on your local machine, please make sure to reset your git user credentials (username and email) to not be the bot"
exit 0