-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
110 lines (97 loc) · 2.51 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
108
109
110
image: 'node:16.15.1'
stages:
- build
- test
- quality
- publish
- deploy
include:
- template: Code-Quality.gitlab-ci.yml
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- Acticlass-App/node_modules/
- Acticlass-API/node_modules/
build_fronted:
stage: build
tags:
- acticlass-runner
script:
- cd Acticlass-App
- npm install
build_backend:
stage: build
tags:
- acticlass-runner
script:
- cd Acticlass-API
- npm install
test_frontend:
stage: test
tags:
- acticlass-runner
script:
- cd Acticlass-App
- npm install
- npm test
test_backend:
stage: test
tags:
- acticlass-runner
before_script:
- cd Acticlass-API
script:
- npm install
- npm test
publish:
image: docker:latest
stage: publish
tags:
- acticlass-runner
variables:
DOCKER_TLS_CERTDIR: ''
DOCKER_HOST: 'tcp://docker:2375'
services:
- docker:dind
script:
- pwd
- echo $SERVER_IP
- docker --version
- docker login -u $DOCKERHUB_USERNAME -p $DOCKERHUB_PASSWORD docker.io
- docker build -t docker.io/acticlass/acticlass:$CI_COMMIT_SHORT_SHA .
- docker push docker.io/acticlass/acticlass:$CI_COMMIT_SHORT_SHA
only:
- master
- developer
deploy:
image: alpine:latest
stage: deploy
tags:
- acticlass-runner
script:
- chmod og= $ID_RSA
- apk update && apk add openssh-client
- ssh -i $ID_RSA -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "docker login -u $DOCKERHUB_USERNAME -p $DOCKERHUB_PASSWORD docker.io"
- ssh -i $ID_RSA -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "docker pull docker.io/acticlass/acticlass:$CI_COMMIT_SHORT_SHA"
- ssh -i $ID_RSA -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "docker container rm -f my-app || true"
- ssh -i $ID_RSA -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "docker run -e DOTENV_KEY='dotenv://:key_55777f98fc7d810d692ed4e8cf8a72e1e3911fed6d1efcbe8fc90cf465c3dab0@dotenv.org/vault/.env.vault?environment=production' -d -p 8073:3000 --name my-app docker.io/acticlass/acticlass:$CI_COMMIT_SHORT_SHA"
environment:
name: production
url: http://172.17.2.145:8073
only:
- master
- developer
code_quality:
stage: quality
variables:
REPORT_FORMAT: html
artifacts:
paths: [gl-code-quality-report.html]
tags:
- acticlass-runner
rules:
- if: $CODE_QUALITY_DISABLED
when: never
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_COMMIT_BRANCH == "developer"
- if: $CI_COMMIT_TAG