deploy.sh 2.5 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

20
21
22
23
24
# 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
25
# loop through all the presentations
Laurent Heirendt's avatar
Laurent Heirendt committed
26
27
28
29
30
31
32
33
34
35
36
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
37
                echo " > -----------------------------------------------------"
Laurent Heirendt's avatar
Laurent Heirendt committed
38
39
40
                echo "Building ... ${d1}"

                # create the required folders in public
Laurent Heirendt's avatar
Laurent Heirendt committed
41
                mkdir -p $rootDir/public/$BLADE/$version
Laurent Heirendt's avatar
Laurent Heirendt committed
42
43
44
45

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

Laurent Heirendt's avatar
Laurent Heirendt committed
46
                # build the unstable version - can be optimized
Laurent Heirendt's avatar
Laurent Heirendt committed
47
                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
48
                git submodule update --recursive --init
Laurent Heirendt's avatar
Laurent Heirendt committed
49

50
                # run contribute
Laurent Heirendt's avatar
Laurent Heirendt committed
51
                cp ../../template/Gruntfile.coffee .
52
53
54
                ln -s ../../theme/package.json package.json
                ln -s ../../theme theme

Laurent Heirendt's avatar
Laurent Heirendt committed
55
                # install npm
56
57
                yarn global add grunt-cli generator-reveal
                yarn install
Laurent Heirendt's avatar
Laurent Heirendt committed
58

Laurent Heirendt's avatar
Laurent Heirendt committed
59
                grunt dist
Laurent Heirendt's avatar
Laurent Heirendt committed
60
                mv public/* $rootDir/public/$BLADE/$version/.
Laurent Heirendt's avatar
Laurent Heirendt committed
61

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

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

                echo "autoredirect file set"

Laurent Heirendt's avatar
Laurent Heirendt committed
75
76
                # move back out
                cd ..
Laurent Heirendt's avatar
Laurent Heirendt committed
77
                echo " > -----------------------------------------------------"
Laurent Heirendt's avatar
Laurent Heirendt committed
78
79
            fi
        done
Laurent Heirendt's avatar
Laurent Heirendt committed
80
        cd "${rootDir}"
Laurent Heirendt's avatar
Laurent Heirendt committed
81
    fi
Laurent Heirendt's avatar
Laurent Heirendt committed
82
done