-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.gitlab-ci.yml
151 lines (132 loc) · 5.04 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
stages:
- test
- deploy
# Cache libraries in between jobs
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- vendor/
test:
# Select image from https://hub.docker.com/_/php/
image: php:7.4
stage: test
before_script:
# Install git, the php image doesn't have installed
- apt-get update -yqq
- apt-get install git unzip zlib1g-dev libzip-dev libpng-dev wget -yqq
# Install mysql driver
- docker-php-ext-install pdo_mysql zip gd
# Install composer
- curl -sS https://getcomposer.org/installer | php
# Install all project dependencies
- php composer.phar install --no-interaction --prefer-dist --no-progress
- sh ./syncSchema.sh
# We test PHP7.4 (the default) with MySQL
script:
- ./vendor/bin/simple-phpunit
deploy:dev:
image: php:7.4
stage: deploy
environment:
name: development
url: https://api.dev.inowas.com
script:
- echo $CI_COMMIT_SHORT_SHA
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
- eval $(ssh-agent -s)
- ssh-add <(echo "$SSH_PRIVATE_KEY")
- mkdir -p ~/.ssh
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
- ssh -t [email protected] 'cd /srv/docker/api.dev.inowas.com &&
docker compose down &&
git checkout dev &&
git fetch --all --tags &&
git pull origin dev &&
docker compose build &&
docker compose up -d --force-recreate &&
docker compose exec -T php composer install --no-dev &&
docker compose exec -T php ./bin/console doctrine:schema:update -f &&
docker compose exec -T php ./bin/console cache:clear -e prod &&
docker compose exec -T php ./bin/console cache:clear -e dev'
- ssh -t [email protected] 'cd /srv/docker/api.dev.inowas.com &&
sh syncSchema.sh'
only:
- dev
deploy:prod:production:
stage: deploy
environment:
name: dss
url: https://api.dss.inowas.com
script:
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
- eval $(ssh-agent -s)
- ssh-add <(echo "$SSH_PRIVATE_KEY")
- mkdir -p ~/.ssh
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
- ssh -t [email protected] 'cd /srv/docker/api.dss.inowas.com &&
docker compose down &&
git checkout master &&
git fetch --all --tags &&
git pull origin master &&
docker compose build &&
docker compose up -d --force-recreate &&
docker compose exec -T php composer install --no-dev &&
docker compose exec -T php ./bin/console doctrine:schema:update -f &&
docker compose exec -T php ./bin/console cache:clear -e prod &&
docker compose exec -T php ./bin/console cache:clear -e dev'
- ssh -t [email protected] 'cd /srv/docker/api.dss.inowas.com &&
sh syncSchema.sh'
only:
- master
deploy:prod:smart-control:
stage: deploy
environment:
name: smart-control
url: https://api.dss.smart-control.inowas.com
script:
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
- eval $(ssh-agent -s)
- ssh-add <(echo "$SSH_PRIVATE_KEY")
- mkdir -p ~/.ssh
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
- ssh -t [email protected] 'cd /srv/docker/api.dss.smart-control.inowas.com &&
docker compose down &&
git fetch --all --tags &&
git checkout master &&
git pull origin master &&
docker compose build &&
docker compose up -d --force-recreate &&
docker compose exec -T php composer install --no-dev &&
docker compose exec -T php ./bin/console doctrine:schema:update -f &&
docker compose exec -T php ./bin/console cache:clear -e prod &&
docker compose exec -T php ./bin/console cache:clear -e dev'
- ssh -t [email protected] 'cd /srv/docker/api.dss.smart-control.inowas.com &&
sh syncSchema.sh'
only:
- master
deploy:prod:training:
stage: deploy
environment:
name: training
url: https://api.training.inowas.com
script:
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
- eval $(ssh-agent -s)
- ssh-add <(echo "$SSH_PRIVATE_KEY")
- mkdir -p ~/.ssh
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
- ssh -t [email protected] 'cd /srv/docker/api.training.inowas.com &&
docker compose down &&
git fetch --all --tags &&
git checkout master &&
git pull origin master &&
docker compose build &&
docker compose up -d --force-recreate &&
docker compose exec -T php composer install --no-dev &&
docker compose exec -T php ./bin/console doctrine:schema:update -f &&
docker compose exec -T php ./bin/console cache:clear -e prod &&
docker compose exec -T php ./bin/console cache:clear -e dev'
- ssh -t [email protected] 'cd /srv/docker/api.training.inowas.com &&
sh syncSchema.sh'
only:
- master