.gitlab-ci.yml 1.47 KB
Newer Older
Yohan Jarosz's avatar
Yohan Jarosz committed
1
2
3
stages:
  - build
  - review
Yohan Jarosz's avatar
Yohan Jarosz committed
4

Yohan Jarosz's avatar
Yohan Jarosz committed
5
6
7
8
variables:
  GIT_STRATEGY: clone


Yohan Jarosz's avatar
add ci  
Yohan Jarosz committed
9
10
11
Build for review:
    stage: build
    before_script:
Yohan Jarosz's avatar
d    
Yohan Jarosz committed
12
13
      - bundle config set path '/home/gitlab-runner/.gem'
      - bundle install && bundle update
Yohan Jarosz's avatar
add ci  
Yohan Jarosz committed
14
15
16
17
18
    script:
      - 'echo "project_id: $CI_PROJECT_ID" > _config_review.yml'    
      - 'echo "project_namespace: $CI_PROJECT_PATH" >> _config_review.yml'
      - 'echo "mr_id: $CI_MERGE_REQUEST_ID" >> _config_review.yml'
      - 'echo "gitlab_host: https://git-r3lab.uni.lu" >> _config_review.yml'
Yohan Jarosz's avatar
d    
Yohan Jarosz committed
19
      - pwd
Yohan Jarosz's avatar
add ci  
Yohan Jarosz committed
20
21
22
23
24
25
26
      - bundle exec jekyll build -d public --config "_config.yml,_config_review.yml"
    artifacts:
      expire_in: 1 month
      paths:
        - public
    variables:
      JEKYLL_ENV: review
Yohan Jarosz's avatar
Yohan Jarosz committed
27
28
    rules:
      - if: '$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME'
Yohan Jarosz's avatar
add ci  
Yohan Jarosz committed
29
30
    tags:
      - review-app
Yohan Jarosz's avatar
Yohan Jarosz committed
31
32


Yohan Jarosz's avatar
Yohan Jarosz committed
33
Publish review:
Yohan Jarosz's avatar
add ci  
Yohan Jarosz committed
34
35
    stage: review
    script:
Yohan Jarosz's avatar
Yohan Jarosz committed
36
      - rsync -av --delete public /srv/nginx/pages/$CI_PROJECT_ID/$CI_MERGE_REQUEST_ID
Yohan Jarosz's avatar
Yohan Jarosz committed
37
    environment:
Yohan Jarosz's avatar
Yohan Jarosz committed
38
      name: review $CI_BUILD_REF_NAME for $CI_PROJECT_PATH
Yohan Jarosz's avatar
Yohan Jarosz committed
39
      url: http://$CI_MERGE_REQUEST_ID-$CI_PROJECT_ID.review.lcsb.uni.lu
Yohan Jarosz's avatar
Yohan Jarosz committed
40
      on_stop: "Un-publish review"
Yohan Jarosz's avatar
Yohan Jarosz committed
41
42
    rules:
      - if: '$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME'
Yohan Jarosz's avatar
add ci  
Yohan Jarosz committed
43
    tags:
Yohan Jarosz's avatar
Yohan Jarosz committed
44
45
46
47
48
      - review-app

Un-publish review:
  stage: review
  script:
Yohan Jarosz's avatar
Yohan Jarosz committed
49
    - rm -rf /srv/nginx/pages/$CI_PROJECT_ID/$CI_MERGE_REQUEST_ID
Yohan Jarosz's avatar
Yohan Jarosz committed
50
51
52
53
  variables:
    GIT_STRATEGY: none
  when: manual
  environment:
Yohan Jarosz's avatar
Yohan Jarosz committed
54
    name: review $CI_BUILD_REF_NAME for $CI_PROJECT_PATH
Yohan Jarosz's avatar
Yohan Jarosz committed
55
56
    action: stop
  tags:
Yohan Jarosz's avatar
Yohan Jarosz committed
57
    - review-app
Yohan Jarosz's avatar
Yohan Jarosz committed
58