deploy.sh 2.52 KB
Newer Older
Laurent Heirendt's avatar
Laurent Heirendt committed
1
2
#!/bin/bash

Laurent Heirendt's avatar
Laurent Heirendt committed
3
PAGEURL="https://courses.lcsb.uni.lu"
Laurent Heirendt's avatar
Laurent Heirendt committed
4

Laurent Heirendt's avatar
Laurent Heirendt committed
5
6
rootDir=$(pwd)
echo $rootDir
Laurent Heirendt's avatar
Laurent Heirendt committed
7

Laurent Heirendt's avatar
Laurent Heirendt committed
8
9
10
11
# clean previous builds
rm -rf $rootDir/public
mkdir $rootDir/public

Laurent Heirendt's avatar
Laurent Heirendt committed
12
13
14
15
16
17
18
19
if [[ $CI_COMMIT_BRANCH == "develop" ]]; then
    version="latest";
elif [[ $CI_COMMIT_BRANCH == "master" ]]; then
    version="stable";
else
    version="unstable";
fi

Laurent Heirendt's avatar
Laurent Heirendt committed
20
# build the unstable version - can be optimized
Laurent Heirendt's avatar
Laurent Heirendt committed
21
#git config submodule.theme.url https://$CI_DEPLOY_USER:$CI_DEPLOY_PASSWORD@git-r3lab.uni.lu/R3-core/outreach/theme.git
Laurent Heirendt's avatar
Laurent Heirendt committed
22
23
git submodule update --recursive --init

Laurent Heirendt's avatar
Laurent Heirendt committed
24
25
26
# output the directory content
ls -lash

27
28
29
30
31
# add matomo
sed -i "/matomohead/r./.ci/analytics/head.html" theme/templates/_index.html
sed -i "/matomopolicy/r./.ci/analytics/policy.html" theme/templates/_index.html
sed -i "/matomobanner/r./.ci/analytics/gdpr-banner.html" theme/templates/_index.html

Laurent Heirendt's avatar
Laurent Heirendt committed
32
33
echo " > LAP included"

Laurent Heirendt's avatar
Laurent Heirendt committed
34
# loop through all the presentations
Laurent Heirendt's avatar
Laurent Heirendt committed
35
36
37
38
39
40
41
42
43
44
45
nBlades=0
for d in $(find . -maxdepth 1 -type d)
do
    if [[ "${d}" == *20* ]]; then
        cd "${d}"
        echo "changed to ${d}"
        for d1 in $(find . -maxdepth 1 -type d)
        do
            if [[ ${#d1} -ge 2 ]]; then
                let "nBlades+=1"
                BLADE=${d1:2}
Laurent Heirendt's avatar
Laurent Heirendt committed
46
                echo " > -----------------------------------------------------"
Laurent Heirendt's avatar
Laurent Heirendt committed
47
48
49
                echo "Building ... ${d1}"

                # create the required folders in public
Laurent Heirendt's avatar
Laurent Heirendt committed
50
                mkdir -p $rootDir/public/$BLADE/$version
Laurent Heirendt's avatar
Laurent Heirendt committed
51
52
53
54

                # change to the blade directory to be built
                cd $BLADE

55
                # run contribute
Laurent Heirendt's avatar
Laurent Heirendt committed
56
                cp ../../template/Gruntfile.coffee .
57
58
59
                ln -s ../../theme/package.json package.json
                ln -s ../../theme theme

Laurent Heirendt's avatar
Laurent Heirendt committed
60
                # install npm
61
62
                yarn global add grunt-cli generator-reveal
                yarn install
Laurent Heirendt's avatar
Laurent Heirendt committed
63

Laurent Heirendt's avatar
Laurent Heirendt committed
64
                grunt dist
Laurent Heirendt's avatar
Laurent Heirendt committed
65
                mv public/* $rootDir/public/$BLADE/$version/.
Laurent Heirendt's avatar
Laurent Heirendt committed
66

Laurent Heirendt's avatar
Laurent Heirendt committed
67
                echo " > latest built for file set ${BLADE}"
Laurent Heirendt's avatar
Laurent Heirendt committed
68

Laurent Heirendt's avatar
Laurent Heirendt committed
69
70
71
                # auto redirect file to the stable version
                echo '<html>\n
                    <head>\n
Laurent Heirendt's avatar
Laurent Heirendt committed
72
                    <meta http-equiv="refresh" content="0; url='$PAGEURL'/'$BLADE'/stable"/>\n
Laurent Heirendt's avatar
Laurent Heirendt committed
73
74
75
76
77
78
79
                    </head>\n
                    <body>\n
                    </bod>\n
                    </html>\n' > $rootDir/public/$BLADE/index.html

                echo "autoredirect file set"

Laurent Heirendt's avatar
Laurent Heirendt committed
80
81
                # move back out
                cd ..
Laurent Heirendt's avatar
Laurent Heirendt committed
82
                echo " > -----------------------------------------------------"
Laurent Heirendt's avatar
Laurent Heirendt committed
83
84
            fi
        done
Laurent Heirendt's avatar
Laurent Heirendt committed
85
        cd "${rootDir}"
Laurent Heirendt's avatar
Laurent Heirendt committed
86
    fi
Laurent Heirendt's avatar
Laurent Heirendt committed
87
done