-
Notifications
You must be signed in to change notification settings - Fork 9
/
.gitlab-ci.yml
59 lines (55 loc) · 1.69 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
image: ruby:2.4.0
before_script:
- >
: "${HEROKU_EMAIL:?Please set HEROKU_EMAIL in your CI/CD config vars}"
- >
: "${HEROKU_AUTH_TOKEN:?Please set HEROKU_AUTH_TOKEN in your CI/CD config vars}"
- curl https://cli-assets.heroku.com/install-standalone.sh | sh
- |
cat >~/.netrc <<EOF
machine api.heroku.com
login $HEROKU_EMAIL
password $HEROKU_AUTH_TOKEN
machine git.heroku.com
login $HEROKU_EMAIL
password $HEROKU_AUTH_TOKEN
EOF
- chmod 600 ~/.netrc
- git config --global user.email "[email protected]"
- git config --global user.name "CI/CD"
variables:
APPNAME_PRODUCTION: niklick-pipeline
test:
stage: test
variables:
POSTGRES_USER: test
POSTGRES_PASSSWORD: test-password
POSTGRES_DB: test
DATABASE_URL: postgres://${POSTGRES_USER}:${POSTGRES_PASSSWORD}@postgres/${POSTGRES_DB}
RAILS_ENV: test
services:
- postgres:alpine
before_script:
- curl -sL https://deb.nodesource.com/setup_8.x | bash
- apt-get update -qq && apt-get install -yqq nodejs libpq-dev
- curl -o- -L https://yarnpkg.com/install.sh | bash
- source ~/.bashrc
- yarn
- gem install bundler --no-ri --no-rdoc
- bundle install -j $(nproc) --path vendor
- bundle exec rake db:setup RAILS_ENV=test
script:
- bundle exec rake spec
- bundle exec rubocop
deploy_to_production:
stage: deploy
environment:
name: production
url: https://$APPNAME_PRODUCTION.herokuapp.com/
script:
- git remote add heroku https://git.heroku.com/$APPNAME_PRODUCTION.git
- git push heroku master
- heroku pg:backups:capture --app $APPNAME_PRODUCTION
- heroku run rails db:migrate --app $APPNAME_PRODUCTION
only:
- master