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

Laurent Heirendt's avatar
Laurent Heirendt committed
3
PAGEURL="https://r3.pages.uni.lu/school/courses"
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
12
# clean previous builds
rm -rf $rootDir/public
mkdir $rootDir/public

# loop through all the presentations
Laurent Heirendt's avatar
Laurent Heirendt committed
13
14
15
16
17
18
19
20
21
22
23
24
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"
                #blades[$nBlades]="$tutorial"
                BLADE=${d1:2}
Laurent Heirendt's avatar
Laurent Heirendt committed
25
                echo " > -----------------------------------------------------"
Laurent Heirendt's avatar
Laurent Heirendt committed
26
27
28
29
                echo "Building ... ${d1}"

                # create the required folders in public
                mkdir $rootDir/public/$BLADE
Laurent Heirendt's avatar
Laurent Heirendt committed
30
31
32
                mkdir $rootDir/public/$BLADE/unstable
                mkdir $rootDir/public/$BLADE/latest
                mkdir $rootDir/public/$BLADE/stable
Laurent Heirendt's avatar
Laurent Heirendt committed
33
34
35
36

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

Laurent Heirendt's avatar
Laurent Heirendt committed
37
                # build the unstable version - can be optimized
Laurent Heirendt's avatar
Laurent Heirendt committed
38
                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
39
                git submodule update --recursive --init
Laurent Heirendt's avatar
Laurent Heirendt committed
40

41
                # run contribute
Laurent Heirendt's avatar
Laurent Heirendt committed
42
                cp ../../template/Gruntfile.coffee .
43
44
45
                ln -s ../../theme/package.json package.json
                ln -s ../../theme theme

Laurent Heirendt's avatar
Laurent Heirendt committed
46
                # install npm
47
48
49
50
                #npm install -g npm@latest yo grunt-cli generator-reveal
                #npm install
                yarn global add grunt-cli generator-reveal
                yarn install
Laurent Heirendt's avatar
Laurent Heirendt committed
51

Laurent Heirendt's avatar
Laurent Heirendt committed
52
53
                grunt dist
                mv public/* $rootDir/public/$BLADE/unstable/.
Laurent Heirendt's avatar
Laurent Heirendt committed
54
                echo " > unstable built for file set ${BLADE}"
Laurent Heirendt's avatar
Laurent Heirendt committed
55

Laurent Heirendt's avatar
Laurent Heirendt committed
56
                # build the master version into stable
Laurent Heirendt's avatar
Laurent Heirendt committed
57
58
                git fetch --tags
                latestTag=$(git describe --tags `git rev-list --tags --max-count=1`)
Laurent Heirendt's avatar
Laurent Heirendt committed
59
                git stash
Laurent Heirendt's avatar
Laurent Heirendt committed
60
61
62
                git checkout $latestTag
                git submodule update --init
                grunt dist
Laurent Heirendt's avatar
Laurent Heirendt committed
63
                mv public/* $rootDir/public/$BLADE/stable/.
Laurent Heirendt's avatar
Laurent Heirendt committed
64
                echo " > stable built for file set ${BLADE}"
Laurent Heirendt's avatar
Laurent Heirendt committed
65
66

                # build the develop version into latest
Laurent Heirendt's avatar
Laurent Heirendt committed
67
                git stash
Laurent Heirendt's avatar
Laurent Heirendt committed
68
69
70
                git checkout -f develop
                git fetch origin develop
                git reset --hard origin/develop
Laurent Heirendt's avatar
Laurent Heirendt committed
71
                git submodule update --init
Laurent Heirendt's avatar
Laurent Heirendt committed
72
                grunt dist
Laurent Heirendt's avatar
Laurent Heirendt committed
73
                mv public/* $rootDir/public/$BLADE/latest/.
Laurent Heirendt's avatar
Laurent Heirendt committed
74
                echo " > latest built for file set ${BLADE}"
Laurent Heirendt's avatar
Laurent Heirendt committed
75

Laurent Heirendt's avatar
Laurent Heirendt committed
76
                # auto redirect file to the stable version
Laurent Heirendt's avatar
Laurent Heirendt committed
77
78
                echo '<html>\n
                    <head>\n
Laurent Heirendt's avatar
Laurent Heirendt committed
79
                    <meta http-equiv="refresh" content="0; url='$PAGEURL'/'$BLADE'/stable"/>\n
Laurent Heirendt's avatar
Laurent Heirendt committed
80
81
82
83
                    </head>\n
                    <body>\n
                    </bod>\n
                    </html>\n' > $rootDir/public/$BLADE/index.html
Laurent Heirendt's avatar
Laurent Heirendt committed
84
85

                echo "autoredirect file set"
Laurent Heirendt's avatar
Laurent Heirendt committed
86
87
88

                # move back out
                cd ..
Laurent Heirendt's avatar
Laurent Heirendt committed
89
                echo " > -----------------------------------------------------"
Laurent Heirendt's avatar
Laurent Heirendt committed
90
91
            fi
        done
Laurent Heirendt's avatar
Laurent Heirendt committed
92
        cd "${rootDir}"
Laurent Heirendt's avatar
Laurent Heirendt committed
93
    fi
Laurent Heirendt's avatar
Laurent Heirendt committed
94
done