-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.sh
80 lines (63 loc) · 3.37 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/bash
# THANKS https://github.com/steveklabnik/automatically_update_github_pages_with_travis_example
# CREATE orphan branch gh-pages
# git checkout --orphan gh-pages
# rm -rf *.md *.json *xml *.sh *.properties src config resources *.yml *.travis.yml .gitignore .editorconfig .scannerwork .sourcemaps documentation node_modules platforms plugins psd www *.keystore LICENSE *.yml *.txt .*.yml
# rm .babelrc .eslintignore .eslintrc.js .stylelintignore .stylelintrc build.js codeclimate-out.html webpack.*.js yarn.lock
# touch .gitignore && nano .gitignore
# type '.idea'
# git add . && git commit -am "Initial Commit" && git push origin -u gh-pages
# git checkout master
echo -e "#####################################################"
echo -e " START DEPLOYING"
echo -e "#####################################################"
# stop executing if any errors occur, by default bash will just continue past any errors to run the next command
# stop executing if an unset variable is encountered, by default bash will use an empty string for the value of such variables.
set -o errexit -o nounset
# Here we ensure that we only deploy when we commit against the master branch,
# if not we just simply abort the deploy, no errors. So this way we can see the
# result of the tests when we make pull request between different branches or
# commit against a different branch than the master.
if [ "$TRAVIS_BRANCH" != "master" ]
then
echo "This commit was made against the $TRAVIS_BRANCH and not the master! No deploy!"
exit 0
fi
# This sets a variable, rev, with the short hash of HEAD.
# We'll use this later in a commit message.
rev=$(git rev-parse --short HEAD)
# We need to cd into wherever our website built.
# With Jekyll, it's _site. But do whatever.
cd documentation
# First, we initialize a new git repository. Yes, a new one. You'll see.
git init
# We then set our user name and user email. This person will have done the commits that go to gh-pages.
# It's not a default branch, so don't worry, GitHub doesn't count these commits as contributions for your graph.
git config user.name "proustibat"
git config user.email "jennifer.proust@gmail.com"
# Next, we add a remote, named upstream, and we set it to our project.
# But we also interpolate that $GH_TOKEN variable,
# which will allow us to push to this repository later.
git remote add upstream "https://$GH_TOKEN@github.com/proustibat/xbks.git"
git remote -v
# We then fetch it and reset to the gh-pages branch.
# Now, git sees this new repository as just some files
# that change your upstream gh-pages branch.
git fetch upstream
git reset upstream/gh-pages
# Sometimes, you'll need some extra files.
# A CNAME is common, which sets a custom domain up.
# You'll need to run whatever commands generate those files for you.
#echo "rustbyexample.com" > CNAME
# We then touch everything, so that git considers all of our local copies fresh.
touch .
# Turn off Jekyll (useful for files that start with an underscore)
# https://help.github.com/articles/files-that-start-with-an-underscore-are-missing/
touch .nojekyll
git status
# We then add all changes, commit them, using our rev from earlier, and then push to upstream.
git add -A .
git commit -m "rebuild pages at ${rev}"
# The -q keeps this a bit more quiet, and you can control the noisiness
# of all these different git commands with a judicious sprinkling of -q.
git push upstream HEAD:gh-pages