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

4
5
6
7
8
stages:
  - test
  - deploy
  - release

9
# This will try to build the web site, and store the result in "build" directory
10
build the web site:
Christophe Trefois's avatar
Christophe Trefois committed
11
  stage: test
12
13
  variables:
    JEKYLL_ENV: production
Christophe Trefois's avatar
Christophe Trefois committed
14
  artifacts:
15
    expire_in: 3 days
Christophe Trefois's avatar
Christophe Trefois committed
16
    paths:
17
18
19
20
21
22
23
    - build  
  before_script:
  - bundle install
  script:  
  - 'echo "baseurl: /$CI_PROJECT_NAME" >> _config_ci.yml'
  - 'echo "url: https://$CI_PROJECT_NAMESPACE.$CI_PAGES_DOMAIN" >> _config_ci.yml'
  - bundle exec jekyll build -d build --config "_config.yml,_config_ci.yml"
Christophe Trefois's avatar
Christophe Trefois committed
24

25
# This will actually deploy the web site when pushing to master
Christophe Trefois's avatar
Christophe Trefois committed
26
27
pages:
  stage: deploy
28
29
30
  rules:
    # Run only on branch named "latest"
    - if: $CI_COMMIT_BRANCH == "latest"
Christophe Trefois's avatar
Christophe Trefois committed
31
  script:
32
33
  - mv build public
  - echo "Your website is available at $CI_PAGES_URL"
Christophe Trefois's avatar
Christophe Trefois committed
34
  artifacts:
35
    expire_in: 3 days
Christophe Trefois's avatar
Christophe Trefois committed
36
37
38
    paths:
    - public

39
40
41
42
43
# This will tag the repository when the version-file changes and the theme successfully builds
tag:
  stage: deploy
  variables:
    VERSION_FILE: "lib/jekyll-theme-lcsb-default.rb"
Jacek Lebioda's avatar
Jacek Lebioda committed
44
45
46
  rules:
    # Run only on branch named "latest"
    - if: $CI_COMMIT_BRANCH == "latest"
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
  script:
    # Make sure that the version exists
    - VERSION=$(cat $VERSION_FILE | grep -o "\d\.\d\.\d")
    - '[[ -z $VERSION ]] && exit -1 || echo "OK, version appears to be correct -> $VERSION"'

    # Create the tag
    - git tag -a $VERSION

    # Publish the tag
    - git push origin $VERSION
  only:
    changes:
      - "lib/jekyll-theme-lcsb-default.rb"

# This will push the gem to ruby-gems when the repository has been tagged
62
63
64
release:
  stage: release
  script:
65
66
    - mkdir -p ~/.gem && echo "$API_KEY_BASE64" | base64 --decode > ~/.gem/credentials && chmod 0600 ~/.gem/credentials
    - gem build jekyll-theme-lcsb-default.gemspec && gem push jekyll-theme-lcsb-default*.gem
67
  rules:
68
    # Run only when there is a new tag
69
70
    - if: $CI_COMMIT_TAG