forked from tscanlin/tocbot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
travis-deploy.sh
48 lines (38 loc) · 1.21 KB
/
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash
# Inspired by: https://medium.com/@nthgergo/publishing-gh-pages-with-travis-ci-53a8270e87db
set -o errexit
# Info.
echo "Running deploy script"
echo "Branch: $TRAVIS_BRANCH"
echo "Is a Pull Request: $TRAVIS_PULL_REQUEST"
# Exit if the branch is not the master branch.
if [ "$TRAVIS_BRANCH" != "master" ]
then
echo "This commit was made against the $TRAVIS_BRANCH and not the master. No deploy."
exit 0
fi
# Exit if the commit is a pull request.
# We only want to build / deploy when pull requests are merged into master.
if [ "$TRAVIS_PULL_REQUEST" != "false" ]
then
echo "This commit is a pull request. No deploy."
exit 0
fi
# Git config.
git config --global user.email "[email protected]"
git config --global user.name "Travis CI"
COMMIT_MESSAGE=$(git log -1 --pretty=%B)
# Build steps (optional).
# Status (optional).
# git status
# git log
# Deploy.
cd out
git init
git add .
git commit -m "Deploy: $COMMIT_MESSAGE"
git push --force --quiet "https://${GITHUB_TOKEN}@github.com/${GITHUB_REPO}.git" master:gh-pages > /dev/null 2>&1
cd ..
# Add dist files.
git commit -am "Adding dist files: $COMMIT_MESSAGE"
git push --quiet "https://${GITHUB_TOKEN}@github.com/${GITHUB_REPO}.git" HEAD:master > /dev/null 2>&1