.gitlab-ci.yml 2.22 KB
Newer Older
Laurent Heirendt's avatar
Laurent Heirendt committed
1
stages:
Laurent Heirendt's avatar
Laurent Heirendt committed
2
  - retrieve
3
  - generate
Laurent Heirendt's avatar
Laurent Heirendt committed
4
5
6
  - build
  - deploy

Laurent Heirendt's avatar
Laurent Heirendt committed
7
retrieve:repo:
8
9
10
  image:
    name: alpine/git:latest
    entrypoint: [""]
Laurent Heirendt's avatar
Laurent Heirendt committed
11
  stage: retrieve
Laurent Heirendt's avatar
Laurent Heirendt committed
12
  script:
13
    - git clone https://$CI_DEPLOY_TOKEN:$CI_DEPLOY_PASSWORD@git-r3lab.uni.lu/R3/school/courses.lcsb.uni.lu.git
Laurent Heirendt's avatar
Laurent Heirendt committed
14
15
16
17
  artifacts:
    expire_in: 1 day
    paths:
      - courses.lcsb.uni.lu
Laurent Heirendt's avatar
Laurent Heirendt committed
18
19
20
  rules:
    - if: $CI_COMMIT_BRANCH == "develop"
    - if: $CI_COMMIT_BRANCH == "master"
Laurent Heirendt's avatar
Laurent Heirendt committed
21

22
generate:index:
Laurent Heirendt's avatar
Laurent Heirendt committed
23
  image: python
24
  stage: generate
Laurent Heirendt's avatar
Laurent Heirendt committed
25
26
  rules:
    - if: $CI_COMMIT_BRANCH == "develop"
Laurent Heirendt's avatar
Laurent Heirendt committed
27
    - if: $CI_COMMIT_BRANCH == "master"
28
29
  script:
    - python .ci/generateIndex.py
30
31
32
33
  artifacts:
    expire_in: 1 day
    paths:
      - courses.lcsb.uni.lu
Laurent Heirendt's avatar
Laurent Heirendt committed
34

Laurent Heirendt's avatar
Laurent Heirendt committed
35
build:website:
36
  image: git-r3lab.uni.lu:4567/r3/docker/jekyll-lcsb
37
  stage: build
Laurent Heirendt's avatar
Laurent Heirendt committed
38
39
40
  rules:
    - if: $CI_COMMIT_BRANCH == "develop"
    - if: $CI_COMMIT_BRANCH == "master"
Laurent Heirendt's avatar
Laurent Heirendt committed
41
  before_script:
42
43
44
    - cd courses.lcsb.uni.lu
    - gem install bundler -v2.0.2
    - bundle install && bundle update jekyll-theme-lcsb-default && bundle update jekyll-theme-lcsb-frozen-components
Laurent Heirendt's avatar
Laurent Heirendt committed
45
    - cd ..
46
  script:
Laurent Heirendt's avatar
Laurent Heirendt committed
47
    - cd courses.lcsb.uni.lu
48
49
50
51
52
53
54
55
56
    - bundle exec jekyll build -d site --config "_config.yml"
    - mv site ../.
    - cd ..
  artifacts:
    expire_in: 1 day
    paths:
      - site
  variables:
    JEKYLL_ENV: production
57

Laurent Heirendt's avatar
Laurent Heirendt committed
58
build:courses:
59
60
61
62
  image: git-r3lab.uni.lu:4567/r3/docker/nodejs-yarn-grunt
  stage: build
  rules:
    - if: $CI_COMMIT_BRANCH == "develop"
Laurent Heirendt's avatar
Laurent Heirendt committed
63
    - if: $CI_COMMIT_BRANCH == "master"
Laurent Heirendt's avatar
Laurent Heirendt committed
64
65
  before_script:
    - git submodule update --init --recursive
Laurent Heirendt's avatar
Laurent Heirendt committed
66
  script:
Laurent Heirendt's avatar
Laurent Heirendt committed
67
    - bash .ci/deploy.sh
Laurent Heirendt's avatar
Laurent Heirendt committed
68
69
70
71
72
  artifacts:
    expire_in: 1 day
    paths:
      - public

Laurent Heirendt's avatar
Laurent Heirendt committed
73
upload:
Laurent Heirendt's avatar
Laurent Heirendt committed
74
  stage: deploy
75
  image: alpine
Laurent Heirendt's avatar
Laurent Heirendt committed
76
77
78
79
80
81
82
83
84
  before_script:
    - 'which ssh-agent || ( apk add --update openssh )'
    - eval $(ssh-agent -s)
    - echo "$B64SSHPRIVKEY" | base64 -d | tr -d '\r' | ssh-add - > /dev/null
    - mkdir -p ~/.ssh && chmod 700 ~/.ssh
    - 'echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
    - echo "$KNOWNHOSTS" > ~/.ssh/known_hosts
    - chmod 644 ~/.ssh/known_hosts
  rules:
Laurent Heirendt's avatar
Laurent Heirendt committed
85
86
    - if: $CI_COMMIT_BRANCH == "develop"
    - if: $CI_COMMIT_BRANCH == "master"
Laurent Heirendt's avatar
Laurent Heirendt committed
87
  script:
88
    - scp -P $SSHPORT -r site/* $SSHCONNECT:~/web/latest
Laurent Heirendt's avatar
Laurent Heirendt committed
89
    - scp -P $SSHPORT -r public/* $SSHCONNECT:~/web/latest