This repository has been archived by the owner on May 21, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
166 lines (159 loc) · 4.03 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
variables:
DOCKER_DRIVER: overlay2
image: trion/ng-cli-karma:8.3.25
stages:
- build
- test
- migrate
- deploy
.ssh:
before_script:
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
- echo "$KEY_STAGING" > ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa
.runner_tags:
tags:
- docker
- linux
build-client:
extends:
- .runner_tags
stage: build
script:
- cd client/
- rm -rf node_modules/
- npm install
- npm run build:$ANGULAR_ENVIRONMENT
- ls
- cd ../..
artifacts:
paths:
- client/dist/
name: "Build client"
expire_in: 1 week
when: on_success
# environment:
# name: $ANGULAR_ENVIRONMENT
build-server:
extends:
- .runner_tags
stage: build
script:
- cd server/
- rm -rf node_modules/
- npm install
- npm run build
- ls
- cd ../..
artifacts:
paths:
- server/dist/
name: "Build Server"
expire_in: 1 week
when: on_success
# environment:
# name: $ANGULAR_ENVIRONMENT
test-e2e:
stage: test
image: trion/ng-cli-e2e:7.0.5
retry: 2
allow_failure: false
dependencies:
- build-server
services:
- postgres:latest
before_script:
- apt update
- apt install -y postgresql-client
- env PGPASSWORD=todo-app psql -h postgres -U todo-app -w todo-app
variables:
POSTGRES_DB: todo-app
POSTGRES_USER: todo-app
POSTGRES_PASSWORD: "todo-app"
script:
- cd server/
- rm -rf config.json
- rm -rf node_modules/
- echo $config_test > config.json
- echo $ormconfig_test > ormconfig.json
- npm install
- npm run migrate:run
- cd ../client
- npm run test:e2e-ci
extends:
- .runner_tags
environment:
name: $ANGULAR_ENVIRONMENT
# # when: manual
only:
- master
migrate-db:
extends:
- .ssh
- .runner_tags
stage: migrate
image: kroniak/ssh-client
script:
- cd server/
- ls
- rm -rf ormconfig.json
- echo $ormconfig > ormconfig.json
- ssh [email protected] rm -rf /srv/www/vhosts/$VHOST_PATH/api/
- ssh [email protected] mkdir -p /srv/www/vhosts/$VHOST_PATH/api/
- scp -r package.json [email protected]:/srv/www/vhosts/$VHOST_PATH/api/
- scp -r ormconfig.json [email protected]:/srv/www/vhosts/$VHOST_PATH/api/
- scp -r tsconfig.json [email protected]:/srv/www/vhosts/$VHOST_PATH/api/
- scp -r src/ [email protected]:/srv/www/vhosts/$VHOST_PATH/api/
- ssh [email protected] "curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.0/install.sh | bash; . ~/.nvm/nvm.sh; nvm --version; nvm use 10.9.0; cd /srv/www/vhosts/$VHOST_PATH/api/; npm install; npm run migrate:run"
dependencies:
- build-server
# environment:
# name: $ANGULAR_ENVIRONMENT
## when: manual
only:
- master
deploy-client:
extends:
- .ssh
- .runner_tags
stage: deploy
image: kroniak/ssh-client
script:
- cd client/
- scp -r dist/client/* [email protected]:/srv/www/vhosts/$VHOST_PATH/
dependencies:
- build-client
# when: manual
only:
- master
# environment:
# name: $ANGULAR_ENVIRONMENT
# url: https://todo-app.w11k.de
#
deploy-server:
extends:
- .ssh
- .runner_tags
stage: deploy
image: kroniak/ssh-client
script:
- cd server/
- echo $config > config.json
- ssh [email protected] mkdir -p /srv/www/vhosts/$VHOST_PATH/api/
- scp -r dist/src/* [email protected]:/srv/www/vhosts/$VHOST_PATH/api/
- scp -r package.json [email protected]:/srv/www/vhosts/$VHOST_PATH/api/
- ssh [email protected] "curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.0/install.sh | bash; . ~/.nvm/nvm.sh; nvm --version; nvm use 10.9.0; cd /srv/www/vhosts/$VHOST_PATH/api/; rm -rf node_modules; npm install"
- scp -r config.json [email protected]:/srv/www/vhosts/$VHOST_PATH/api/
- ssh [email protected] chmod 644 /srv/www/vhosts/$VHOST_PATH/api/config.json
- ssh [email protected] sudo supervisorctl restart $SERVER_SERVICE
after_script:
- ls
# environment:
# name: $ANGULAR_ENVIRONMENT
dependencies:
- build-server
## when: manual
only:
- master