-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
85 lines (78 loc) · 1.8 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
#image: ruby:2.4.2
image: docker:18.09.6
stages:
- build
- test
# - review
# - stage
- production
variables:
# DATABASE_URL: 'mongodb://mongo/user_posts'
VERSION: '0.3'
REDDIT_IP: '35.195.46.237'
#before_script:
# - cd reddit
# - bundle install
build_job:
stage: build
# services:
# - mongo:latest
script:
# - ruby simpletest.rb
- docker build -t reddit:$VERSION reddit/
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD
- docker tag reddit:$VERSION $CI_REGISTRY_USER/otus-reddit:$VERSION
- docker push $CI_REGISTRY_USER/otus-reddit:$VERSION
test_unit_job:
stage: test
script:
- docker run --name test_unit -d $CI_REGISTRY_USER/otus-reddit:$VERSION
- docker exec -i test_unit ruby -Creddit simpletest.rb
- docker rm -f test_unit
#test_integration_job:
# stage: test
# script:
# - echo 'Testing 2'
#
#deploy_dev_job:
# stage: review
# script:
# - echo 'Deploy'
# environment:
# name: dev
# url: http://dev.example.com
#
#branch review:
# stage: review
# script: echo "Deploy to $CI_ENVIRONMENT_SLUG"
# environment:
# name: branch/$CI_COMMIT_REF_NAME
# url: http://$CI_ENVIRONMENT_SLUG.example.com
# only:
# - branches
# except:
# - master
#
#staging:
# stage: stage
# only:
# - /^\d+\.\d+\.\d+/
# when: manual
# script:
# - echo 'Deploy'
# environment:
# name: stage
# url: https://beta.example.com
production:
stage: production
image: ruby:2.4.2
# only:
# - /^\d+\.\d+\.\d+/
when: manual
script:
- eval $(ssh-agent -s)
- ssh-add <(echo "$SSH_PRIVATE_KEY")
- ssh -o "StrictHostKeyChecking=no" appuser@$REDDIT_IP "sudo docker rm -f reddit && sudo docker run --name reddit -d -p 9292:9292 $CI_REGISTRY_USER/otus-reddit:$VERSION"
environment:
name: production
url: http://$REDDIT_IP:9292