-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy path.travis-build.sh
48 lines (33 loc) · 1.49 KB
/
.travis-build.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
# Get the last commit author to see if we should continue
AUTHOR=$(git show -p | grep Author)
# Check to see if this is a pull request if so skip the test because it was ran during the initial commit.
if [ "$AUTHOR" != "Author: Travis-CI <travis@travis-ci.org>" -a "$TRAVIS_PULL_REQUEST" == "false" ]; then
echo -e "Starting to update GitHub Pages\n"
#copy data we're interested in to other place
echo -e "Copying new files to a temp folder\n"
cp -R . $HOME/dev
#go to home and setup git
cd $HOME
git config --global user.email "travis@travis-ci.org"
git config --global user.name "Travis"
#using token clone gh-pages branch
echo -e "Cloning repo\n"
git clone --quiet --branch=gh-pages https://esteinborn:${GH_TOKEN}@github.com/empirejustice/dev.foreclosureguide.git gh-pages > /dev/null
#go into directory and copy data we're interested in to that directory
echo -e "Entering repo folder\n"
cd gh-pages
echo -e "Deleting all existing repo content except for .git folder\n"
# The next line came from Stack Overflow, love that site!
# http://stackoverflow.com/a/22340057/682288
find . -path ./.git -prune -o -exec rm -rf {} \; 2> /dev/null
echo -e "Copying new files into repo\n"
cp -Rf $HOME/dev/* .
rm CNAME
#add, commit and push files
git add -A -f .
git commit -m "Travis build $TRAVIS_BUILD_NUMBER pushed to gh-pages"
git push -fq origin gh-pages > /dev/null
echo -e "Done creating GitHub Pages branch!\n"
else
echo -e "Skipping after script."
fi