.gitlab-ci.yml 1.41 KB
Newer Older
1
2
# In case something goes horribly wrong, you can fall back to `image: ruby:latest`
image: git-r3lab.uni.lu:4567/r3/docker/jekyll-lcsb:1.0
Christophe Trefois's avatar
Christophe Trefois committed
3

4
5
6
7
8
9
build the website:
  stage: build
  before_script:
  - gem install bundler -v2.0.2
  - bundle install && bundle update jekyll-theme-lcsb-default && bundle update jekyll-theme-lcsb-frozen-components
  script:
10
  - bundle exec jekyll build -d build --config "_config.yml,_config_staticpages.yml"
11
12
13
14
15
16
17
  - 'echo $CI_COMMIT_SHA > build/version'
  artifacts:
    expire_in: 3 days
    paths:
    - build
  variables:
    JEKYLL_ENV: production
Christophe Trefois's avatar
Christophe Trefois committed
18

19
20
21

## Deploys the website to a separate VM
Deploy to production:
Christophe Trefois's avatar
Christophe Trefois committed
22
  stage: deploy
23
24
25
26
27
28
29
30
31
  image: alpine:3.1
  before_script:
    - 'which ssh-agent || ( apk add --update openssh )'
    - eval $(ssh-agent -s)
    - echo "$SSHPRIVKEY" | 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
Christophe Trefois's avatar
Christophe Trefois committed
32
  script:
33
    # don't forget to create ~/web/latest folder manually in the initial configuration on the VM!
34
35
    - ssh -p $SSHPORT $SSHCONNECT "mkdir -p ~/web/r3lab_$CI_JOB_ID"
    - scp -P $SSHPORT -r build/* $SSHCONNECT:~/web/r3lab_$CI_JOB_ID
36
    - ssh -p $SSHPORT $SSHCONNECT "cd ~/web/latest && ln -fs ../r3lab_$CI_JOB_ID/* . && cd .. && find . -type d -name 'r3lab*' -not -newermt '-1 minutes' -exec rm -rf {} +"