forked from bccp/website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rebuild-site.sh
69 lines (57 loc) · 1.58 KB
/
rebuild-site.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
#! /bin/bash
# this script will generate the site in $HOME/site
#
# it clones and builds the repository in $HOME/build
#
# it assumes git, python and nikola are installed.
#
# it can be triggered by the server via a github hook.
#
# note that in our current setup,
# this file needs to be manually updated on the server.
#
# subsites.txt in $HOME/build/website
function setup_subsite {
local gitbranch=$1
local localname=$2
local sitetype=$3
local siterelroot=$4
local siteroot=$HOME/build/$localname/$siterelroot
echo setting up subsite $gitbranch at $siteroot
pushd $HOME/build
git clone https://github.com/bccp/workshops -b $gitbranch $localname
cd $localname
echo 'working from'
pwd
git fetch --all
git checkout -B $gitbranch origin/$gitbranch
git reset --hard origin/$gitbranch
if [ "x$type" == "xnikola" ]; then
nikola build 2>&1
fi
popd
rsync -av --exclude=".*" $siteroot $HOME/site/$localname
# return $siteroot;
}
mkdir -p $HOME/build
pushd $HOME/build
git clone https://github.com/bccp/website website
cd website
git fetch --all
git checkout master
git reset --hard origin/master
nikola build 2>&1
rsync -av --exclude=".*" output/* $HOME/site/
popd
CONFDIR=$HOME/build/website
echo ===================
cat $CONFDIR/subsites.txt
echo ===================
IFS=" |"
while read branch name sitetype reldir; do
echo ==================
if [ -z $branch ]; then continue; fi
setup_subsite "$branch" "$name" "$sitetype" "$reldir"
echo ==================
done < $CONFDIR/subsites.txt
#setup_subsite https://github.com/bccp/website-2017-neutral-hydrogen 2017-neutral-hydrogen html .