.gitlab-ci.yml 1.91 KB
Newer Older
Sander van Kasteel's avatar
Sander van Kasteel committed
1
image: ruby:2.6
2 3 4 5

variables:
  JEKYLL_ENV: production

6 7 8
include:
  template: Verify/Browser-Performance.gitlab-ci.yml

9 10 11
stages:
  - build
  - test
12
  - deploy
13 14
  - performance
  - performance_report
15 16 17 18 19 20 21
  
cache:
  key: ${$CI_JOB_STAGE-$CI_COMMIT_REF_SLUG}
  paths:
    - vendor/

before_script:
Sander van Kasteel's avatar
Sander van Kasteel committed
22
  - gem install bundler -v 2.0.2
23 24 25 26 27
  - bundle install --path vendor

building:
  stage: build
  script:
28
    - bundle exec jekyll build --config _config.yml
29 30 31 32 33 34 35
  artifacts:
    paths:
     - _site/

testing:
  stage: test
  script:
Sander van Kasteel's avatar
Sander van Kasteel committed
36
    - bundle exec htmlproofer ./_site -t --check-html --check-opengraph
37 38
    - bundle exec jekyll build --config _config.yml,_config-prod.yml
    - bundle exec ruby -Ilib:test tests/*.rb
39 40
  dependencies:
    - building
41

Sander van Kasteel's avatar
Sander van Kasteel committed
42 43 44
deploy:
  stage: deploy
  script:
45 46
    - apt-get update && apt-get install -y sshpass rsync libjpeg-turbo-progs gifsicle pngcrush
    - JEKYLL_ENV=production bundle exec jekyll build --config _config.yml,_config-prod.yml
47
    - bundle exec jekyll algolia
48
    - bundle exec rake optimizeimages
49
    - bundle exec rake minify_html
Sander van Kasteel's avatar
Sander van Kasteel committed
50 51 52
    - bundle exec rake deploy -- --user=$DEPLOY_USER --password=$DEPLOY_PASS --host=$DEPLOY_HOST --directory=$DEPLOY_DIR
    - bundle exec rake notify -- --cloudflare_api=$CLOUDFlARE_KEY
  only:
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
    - master

review:
  stage: deploy
  environment:
    name: review/$CI_COMMIT_REF_SLUG
    url: https://$CI_COMMIT_REF_SLUG--sandervankasteel-blog.netlify.com
  script:
    - echo $CI_ENVIRONMENT_URL > environment_url.txt
  artifacts:
    paths:
      - environment_url.txt
  only:
    - branches
  except:
    - master

performance:
  variables:
    SITESPEED_OPTIONS: -d 2
  dependencies:
    - review
  before_script:
    - export URL=$(cat environment_url.txt)

performance_reporter:
  stage: performance_report
80
  image: sandervankasteel/gitlab-performance-reporter:1.0.1
81 82 83 84 85
  before_script: []
  dependencies:
    - performance
  script:
    - python /app/src/main.py --token $GITLAB_ACCESS_TOKEN