.gitlab-ci.yml 2.24 KB
Newer Older
Cool Fire's avatar
Cool Fire committed
1 2 3 4 5 6
---
stages:
  - syntax
  - linting
  - testing
  - deploy
7
syntax_ruby_2-6:
Cool Fire's avatar
Cool Fire committed
8
  stage: syntax
9
  image: ruby:2.6-alpine
Cool Fire's avatar
Cool Fire committed
10
  script:
11
    - ruby -v
Cool Fire's avatar
Cool Fire committed
12
    - find . -name '*\.rb' -exec bash -c 'echo -ne "{}\t\t\t" && ruby -c {}' \;
13
syntax_erb_2-6:
Cool Fire's avatar
Cool Fire committed
14
  stage: syntax
15
  image: ruby:2.6-alpine
Cool Fire's avatar
Cool Fire committed
16
  script:
17
    - ruby -v
Cool Fire's avatar
Cool Fire committed
18
    - find . -name '*\.erb' -exec bash -c 'echo -ne "{}\t\t\t" && erb -P -x  {} | ruby -c' \;
19 20
syntax_ruby_2-3:
  stage: syntax
Cool Fire's avatar
Cool Fire committed
21
  image: ruby:2.3-alpine
22
  script:
23
    - ruby -v
24 25 26
    - find . -name '*\.rb' -exec bash -c 'echo -ne "{}\t\t\t" && ruby -c {}' \;
syntax_erb_2-3:
  stage: syntax
Cool Fire's avatar
Cool Fire committed
27
  image: ruby:2.3-alpine
28
  script:
29
    - ruby -v
30
    - find . -name '*\.erb' -exec bash -c 'echo -ne "{}\t\t\t" && erb -P -x  {} | ruby -c' \;
Cool Fire's avatar
Cool Fire committed
31 32
lint_ruby:
  stage: linting
33
  image: ruby:2.6-alpine
Cool Fire's avatar
Cool Fire committed
34
  script:
35
    - apk add --update alpine-sdk
36
    - gem install --no-document rubocop
Cool Fire's avatar
Cool Fire committed
37 38 39
    - rubocop -l -f s
lint_yaml:
  stage: linting
40
  image: python:3.6
Cool Fire's avatar
Cool Fire committed
41
  script:
42 43 44
    - pip3 install yamllint
    - yamllint -v
    - yamllint -s content/*.yaml
45
rack_test_2-6:
Cool Fire's avatar
Cool Fire committed
46
  stage: testing
47
  image: ruby:2.6-alpine
Cool Fire's avatar
Cool Fire committed
48
  script:
49
    - apk add --update alpine-sdk mysql-dev
Cool Fire's avatar
Cool Fire committed
50
    - bundle install
51
    - touch .current
Cool Fire's avatar
Cool Fire committed
52
    - ruby deployment/create_config.rb > config.yaml
Cool Fire's avatar
Cool Fire committed
53
    - ruby test.rb
54 55 56 57
rack_test_2-3:
  stage: testing
  image: ruby:2.3-alpine
  script:
58
    - apk add --update alpine-sdk mysql-dev
59 60
    - bundle install
    - touch .current
Cool Fire's avatar
Cool Fire committed
61
    - ruby deployment/create_config.rb > config.yaml
62
    - ruby test.rb
Cool Fire's avatar
Cool Fire committed
63
deploy_to_production:
Cool Fire's avatar
Cool Fire committed
64
  stage: deploy
65
  image: ubuntu:18.04
Cool Fire's avatar
Cool Fire committed
66 67
  only:
    - master
Cool Fire's avatar
Cool Fire committed
68 69 70
  environment:
    name: production
    url: https://signup.insomnia247.nl
Cool Fire's avatar
Cool Fire committed
71
  script:
Cool Fire's avatar
Cool Fire committed
72
    - apt-get update
73
    - apt-get install -y -qq ruby curl
Cool Fire's avatar
Cool Fire committed
74 75 76 77 78
    - 'which ssh-agent || (apt-get install -y -qq openssh-client)'
    - eval $(ssh-agent -s)
    - ssh-add <(echo "$SSH_PRIVATE_KEY")
    - mkdir -p ~/.ssh
    - echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
Cool Fire's avatar
Cool Fire committed
79
    - ruby deployment/create_config.rb > config.yaml
Cool Fire's avatar
Cool Fire committed
80 81 82 83
    - bash deployment/pull_code.sh
    - bash deployment/set_git_tag.sh
    - bash deployment/populate_config.sh
    - bash deployment/restart_application.sh
Cool Fire's avatar
Cool Fire committed
84
    - curl -XPOST nanoapi.insomnia247.nl/v1/message -d "key=$NANOBOT_API_KEY&dest=#shells&message=Deployed new version of signup-site to production."