-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.gitlab-ci.yml
107 lines (101 loc) · 2.9 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
image: docker:20.10.22
services:
- docker:20.10.22-dind
variables:
dev: dev
re7: preprod
master: prod
api_docker_image: '$CI_REGISTRY/cour-de-cassation/juritcom/api:$CI_COMMIT_BRANCH-$CI_COMMIT_SHORT_SHA'
batch_docker_image: '$CI_REGISTRY/cour-de-cassation/juritcom/batch:$CI_COMMIT_BRANCH-$CI_COMMIT_SHORT_SHA'
stages:
- test
- build
- deploy
#test:
# stage: test
# services:
# - docker:20.10.22
# variables:
# HTTP_PROXY: $HTTP_PROXY_DEV
# HTTPS_PROXY: $HTTPS_PROXY_DEV
# script:
# - echo $CI_JOB_TOKEN | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY
# - docker build
# --build-arg http_proxy=$HTTP_PROXY
# --build-arg https_proxy=$HTTPS_PROXY
# --target test
# -t juritcom-test .
# ##- docker run -e HTTP_PROXY=$HTTP_PROXY -e HTTPS_PROXY=$HTTPS_PROXY juritcom-test npm audit
# - docker run -e HTTP_PROXY=$HTTP_PROXY -e HTTPS_PROXY=$HTTPS_PROXY juritcom-test npm run format
# - docker run -e HTTP_PROXY=$HTTP_PROXY -e HTTPS_PROXY=$HTTPS_PROXY juritcom-test npm run lint
# - docker run -e HTTP_PROXY=$HTTP_PROXY -e HTTPS_PROXY=$HTTPS_PROXY juritcom-test npm test
# - echo 'ok'
# only:
# - master
# - re7
# - dev
# tags:
# - docker
build_api:
stage: build
# needs: ['test']
variables:
HTTP_PROXY: $HTTP_PROXY_DEV
HTTPS_PROXY: $HTTPS_PROXY_DEV
script:
- echo $CI_JOB_TOKEN | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY
- docker build
--build-arg http_proxy=$HTTP_PROXY
--build-arg https_proxy=$HTTPS_PROXY
--target api
-t $api_docker_image .
- docker push $api_docker_image
only:
- master
- re7
- dev
tags:
- docker
build_batch:
stage: build
# needs: ['test']
variables:
HTTP_PROXY: $HTTP_PROXY_DEV
HTTPS_PROXY: $HTTPS_PROXY_DEV
script:
- echo $CI_JOB_TOKEN | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY
- docker build
--build-arg http_proxy=$HTTP_PROXY
--build-arg https_proxy=$HTTPS_PROXY
--target batch
-t $batch_docker_image .
- docker push $batch_docker_image
only:
- master
- re7
- dev
tags:
- docker
deploy_juritcom:
stage: deploy
image: alpine/ansible:2.16.1
variables:
DOLLAR: $$
script:
- inventaire=$(eval "echo \$$CI_COMMIT_BRANCH")
- mkdir /root/.ssh
- cat $SSH_KEY > /root/.ssh/id_rsa
- cat $KNOWN_HOSTS > /root/.ssh/known_hosts
- chmod 600 /root/.ssh/id_rsa
- chmod 600 /root/.ssh/known_hosts
- ansible-playbook -e juritcom_api_image=$api_docker_image -e juritcom_batch_image=$batch_docker_image -i ansible/inventory/$inventaire.yml ansible/deploy_juritcom.yml --vault-password-file=$ANSIBLE_VAULT_PASS
rules:
- if: $CI_COMMIT_BRANCH == "master"
when: manual
- if: $CI_COMMIT_BRANCH == "dev" || $CI_COMMIT_BRANCH == "re7"
when: on_success
tags:
- docker
needs:
- build_api
- build_batch