-
Notifications
You must be signed in to change notification settings - Fork 13
/
prepare.sh
60 lines (51 loc) · 1.69 KB
/
prepare.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
#!/bin/bash
function error_exit
{
echo -e "\e[01;31m$1\e[00m" 1>&2
exit 1
}
set -e
if [ "$TRAVIS_PULL_REQUEST" == "false" ] && ( [ -f "master" ] || [ -f "development" ]); then
echo -e "Checkout composite repository from gh-pages\n"
cwd=$(pwd)
# create temporary deployment work directory
mkdir $HOME/deployment-work
# setup git and clone gh-pages branch into deployment work directory
git config --global user.email "[email protected]"
git config --global user.name "Travis Deployer"
git clone --branch=gh-pages https://fappel:${GH_TOKEN}@github.com/fappel/xiliary.git $HOME/deployment-work > /dev/null 2>&1 || error_exit "Error cloning gh-pages"
# remove web content
if [ -f "master" ]; then
echo -e "Prepare deployment of branch master\n"
export DEPLOY_WORK_DIRECTORY=""
# cd does not work with set -e
set +e
cd $HOME/deployment-work
set -e
fi
if [ -f "development" ]; then
echo -e "Prepare deployment of branch development\n"
export DEPLOY_WORK_DIRECTORY="development"
# cd does not work with set -e
set +e
cd $HOME/deployment-work/development
set -e
fi
echo -e "Build deployment directory is '$DEPLOY_WORK_DIRECTORY'"
echo -e "Working directory is '$(pwd)'"
rm -f *.html
echo -e "removed html resources"
rm -rf ./assets
echo -e "cleared assets folder"
rm -rf ./images
echo -e "cleared images folder"
rm -rf ./development
echo -e "cleared development repository content"
# go back to the directory where we started
# cd does not work with set -e
set +e
cd $cwd
echo -e "Working directory is '$(pwd)'"
set -e
echo -e "\nDone with composite repository deployment preparations\n"
fi