-
Notifications
You must be signed in to change notification settings - Fork 34
/
deploy.sh
executable file
·34 lines (28 loc) · 1003 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
#!/usr/bin/env bash
#
# Force-push the built HTML to the `gh-pages` branch.
#
set -e
DEPLOY_DIR=~/project/gh-pages
# trust GitHub server keys
if [ ! -d ~/.ssh/ ]; then
mkdir ~/.ssh/
fi
ssh-keyscan github.com >> ~/.ssh/known_hosts
# stage generated HTML for GitHub Pages
git clone --quiet --branch=gh-pages $CIRCLE_REPOSITORY_URL $DEPLOY_DIR
rsync --archive --recursive --verbose --remove-source-files $HOME/project/_site/* $DEPLOY_DIR
# git client setup
cd $DEPLOY_DIR
git config --global push.default simple
git config --global user.email $(git --no-pager show --no-patch --format='%ae' HEAD)
if [ -n $CIRCLE_USERNAME ]; then
git config --global user.name $CIRCLE_USERNAME
else
git config --global user.name "Committer not registered on CircleCI"
fi
git config --global --get-regexp "(push.default|user.(email|name))"
# force push to GitHub Pages
git add --force .
git commit --verbose --message="Deploy build $CIRCLE_BUILD_NUM [ci skip]" || true
git push --verbose --force origin gh-pages