-
Notifications
You must be signed in to change notification settings - Fork 6
/
travis_deploy.sh
30 lines (25 loc) · 1017 Bytes
/
travis_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
#!/bin/bash
# To be run whenever the master branch is updated. The Travis-encrypted GitHub
# token allows us to push to the gh-pages branch of the repo.
#
# This script assumes that `make publish` was performed beforehand and thus the
# output/ directory is up-to-date.
set -x
printf 'Running GitHub Pages deployment script.\n'
git --version
# set up git and GitHub access
git config user.name 'AutoBuild'
git config user.email '[email protected]'
git config credential.helper "store --file=.git/credentials"
echo "https://${GH_TOKEN}:[email protected]" > .git/credentials
# switch to branch gh-pages and get the fresh build
git remote set-branches --add origin gh-pages
git fetch origin
git branch -a
git checkout origin/gh-pages
rsync -rv --delete --exclude output/ --exclude .git/ --exclude .gitignore --exclude CNAME --exclude pelican-plugins/ output/ .
# commit new docs folder and push
git add .
git commit -m "Automatically updated GitHub pages"
git push origin HEAD:gh-pages
rm .git/credentials