-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.gitlab-ci.yml
90 lines (79 loc) · 2.18 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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
80
81
82
83
84
85
86
87
88
89
90
# base image
image: "ruby:2.5.3"
# Services
services:
- postgres:latest
# default variables
variables:
RAILS_ENV: test
POSTGRES_DB: tamashii
NODE_VERSION: 10.0.0
YARN_VERSION: 1.15.2
DATABASE_URL: "postgresql://postgres:postgres@postgres:5432/$POSTGRES_DB"
# build stages
stages:
- test
- staging
- production
# cache gems in between builds
cache:
paths:
- vendor/ruby
- node_modules
# this is a basic example for a gem or script which doesn't use
# services such as redis or postgres
before_script:
- if [[ ! -f /usr/local/bin/node ]]; then curl -SLO https://nodejs.org/dist/v$NODE_VERSION/node-v${NODE_VERSION}-linux-x64.tar.xz && tar -xJf node-v${NODE_VERSION}-linux-x64.tar.xz -C /usr/local --strip-components=1; fi
- curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
- apt-get update && apt-get install apt-transport-https -y
- echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
- apt-get update && apt-get install yarn -y
- gem install bundler -v 1.17.3 # bundler is not installed with the image
- ruby -v
- node -v
- yarn -v
- bundle install -j $(nproc) --path vendor # install dependencies into ./vendor/ruby
- yarn install
# jobs
rspec:
stage: test
script:
- bundle exec rake db:schema:load
- bundle exec rspec -p
rubocop:
stage: test
services: []
before_script:
- gem install rubocop -v 0.49.1
script:
- rubocop
eslint:
stage: test
image: "node:10"
services: []
before_script:
- yarn
script:
- yarn run eslint
scsslint:
stage: test
services: []
before_script:
- gem install scss_lint
script:
- scss-lint app/assets/stylesheets/
deploy_to_production:
stage: production
only:
- master
before_script:
- gem install bundler -v 1.17.3
- bundle install -j $(nproc) --path vendor
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
- eval $(ssh-agent -s)
- ssh-add <(echo "$SSH_PRIVATE_KEY")
- mkdir -p ~/.ssh
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
environment: production
script:
- bundle exec cap production deploy