-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.gitlab-ci.yml
69 lines (57 loc) · 1.67 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
image : node:latest
stages:
- install
- test
- heroku
- build-image
- deploy
cache :
paths :
- node_modules/
install :
stage : install
artifacts:
paths:
- node_modules/
script:
- npm install
test :
stage : test
script :
- npm run test
heroku:
stage: heroku
image: ruby:latest
script:
- apt-get update -qy
- apt-get install -y ruby-dev
- gem install dpl
- dpl --provider=heroku --app=budev --api-key=d2da7495-2783-4633-ba2e-817d155d2dee
only:
- master
build-image :
image: docker:stable
stage: build-image
services:
- docker:18-dind
tags:
- docker_ci_build
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker build -t $CI_REGISTRY_IMAGE:latest --build-arg HTTP_PROXY="http://proxy.univ-lyon1.fr:3128" --build-arg HTTPS_PROXY="http://proxy.univ-lyon1.fr:3128" --build-arg NO_PROXY="127.0.0.0/16,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,localhost,.novalocal,.univ-lyon1.fr" .
- docker push $CI_REGISTRY_IMAGE:latest
only:
- deploy
- master
production:
stage: deploy
before_script:
- apt-get update -qq && apt-get install -y -qq sshpass
script:
- echo $CI_REPOSITORY_URL
- export SSHPASS=$PASSWORD
- sshpass -e ssh -o stricthostkeychecking=no $USER@$HOSTNAME "if cd $CI_PROJECT_NAME; then docker-compose down && cd .. && rm -rf $CI_PROJECT_NAME; fi && git clone $CI_REPOSITORY_URL && cd $CI_PROJECT_NAME && git checkout deploy && cd .."
- sshpass -e ssh -o stricthostkeychecking=no $USER@$HOSTNAME "cd $CI_PROJECT_NAME && docker image rm $CI_REGISTRY_IMAGE:latest && docker-compose up -d"
only:
- deploy
- master