.gitlab-ci.yml 2.81 KB
Newer Older
1
# In case something goes horribly wrong, you can fall back to `image: ruby:2.5`
2
image: git-r3lab.uni.lu:4567/r3/docker/jekyll-lcsb:1.4
3

Jacek Lebioda's avatar
Jacek Lebioda committed
4
5
6
7
8
9
10
11
12
stages:
  - build
  - generate_index
  - deploy

build_pages:
  stage: build
  variables:
    JEKYLL_ENV: production
13
    BUNDLER_VERSION: 2.0.2
Jacek Lebioda's avatar
Jacek Lebioda committed
14
15
16
17
  artifacts:
    expire_in: 1 day
    paths:
      - build
18
19
20
21
22
23
24
25
26
27
28
29
30
31
  before_script:
    - gem install bundler:$BUNDLER_VERSION && bundle install  
  script:
    # Generate the configuration for forks (will use Gitlab Pages on personal namespaces)
    - 'echo "url: https://$CI_PROJECT_NAMESPACE.$CI_PAGES_DOMAIN\nbaseurl: /$CI_PROJECT_NAME" >> _config_gitlab_pages.yml'

    # If there is no config for the current branch, use the one for Gitlab Pages
    - 'if [ ! -f "_config_$CI_COMMIT_REF_NAME.yml" ]; then mv _config_gitlab_pages.yml _config_$CI_COMMIT_REF_NAME.yml; fi'

    # Display, which configuration is used
    - 'echo "Configuration: " && cat "_config_$CI_COMMIT_REF_NAME.yml"'

    # Run Jekyll with custom configuration
    - bundle exec jekyll build -d build --config "_config.yml,_config_$CI_COMMIT_REF_NAME.yml"
32

Jacek Lebioda's avatar
Jacek Lebioda committed
33
34
35
36

generate the search index:
  stage: generate_index
  image: node:13.8.0-slim
37
38
39
  variables:
    LUNR_VERSION: 2.3.8
    DIRECTORY: build
Jacek Lebioda's avatar
Jacek Lebioda committed
40
41
42
43
44
45
46
  script:
    - bash .ci/build_indices.sh
    - mv build processed_build
  artifacts:
    expire_in: 1 day
    paths:
      - processed_build
47

48
# Deploy to Gitlab Pages - to be run only by forks
49
pages:
Jacek Lebioda's avatar
Jacek Lebioda committed
50
  image: alpine:3.11.3
51
  stage: deploy
Jacek Lebioda's avatar
Jacek Lebioda committed
52
  rules:
53
    - if: '$CI_PROJECT_NAMESPACE != "R3" && $CI_PROJECT_NAMESPACE != "R3-core"'
54
  script:
55
56
57
    # For safety reasons:
    - sleep 3600 && exit -1
    - mv processed_buildXXXXX publicXXXX
58
  artifacts:
59
    expire_in: 1 week
60
61
    paths:
      - public
Jacek Lebioda's avatar
Jacek Lebioda committed
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79

## Deploys the website to a separate VM
Deploy to production:
  stage: deploy
  image: alpine:3.1
  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:
    - if: '$CI_COMMIT_BRANCH == "develop" && $CI_PROJECT_PATH == "R3/howto-cards"'
    - if: '$CI_COMMIT_BRANCH == "master" && $CI_PROJECT_PATH == "R3/howto-cards"'
    - if: '$CI_COMMIT_BRANCH == "16-deploy-to-staticpages-vm"'
  script:
80
81
82
    # Disable that for now
    - sleep 3600 && exit -1
    - ssh -p $SSHPORT $SSHCONNECT "mkdir -p ~/sources/$CI_COMMIT_BRANCH/$CI_JOB_ID ~/master ~/develop"
Jacek Lebioda's avatar
Jacek Lebioda committed
83
    - scp -P $SSHPORT -r processed_build/* $SSHCONNECT:~/sources/public/web_$CI_JOB_ID
84
    - ssh -p $SSHPORT $SSHCONNECT "cd ~/master && ln -fs ~/sources/public/web_$CI_JOB_ID/* . && cd ~/sources/public/ && find . -type d -not -newermt '-1 minutes' -exec rm -rf {} +;"
Jacek Lebioda's avatar
Jacek Lebioda committed
85