-
Notifications
You must be signed in to change notification settings - Fork 63
/
Copy path.gitlab-ci.yml
281 lines (220 loc) · 11.4 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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
image: smmccabe/docker:latest
variables:
MYSQL_DATABASE: drupal
MYSQL_SQL_TO_RUN: 'GRANT ALL ON *.* TO "testrunner"@"%";'
MYSQLD_RAM_SIZE: '1024'
# jobs do not need to be present for all stages, if a stage has no jobs it will just be ignored
stages:
- build
- test
- deploy
- post
code_standards:
stage: test
script:
# runs the Drupal code standards checks on our custom code
# the Drupal Code Standards come from the Coder module, which is automatically part of the base testing image
- rm web/themes/custom/commerce_2_demo/node_modules -rf
- ./bin/phpcs --standard=Drupal -n --extensions=php,module,inc,install,test,profile,theme,info,txt,md --file-list=.phpcs-files --ignore=*.css
debt:
stage: test
script:
- phpdebt web/modules/custom
codequality:
# It won't make sense to run codequality on deploy branches, because we
# are assuming that the developer has already addressed the problems.
except:
- uat
- master
image: docker:stable
variables:
DOCKER_DRIVER: overlay2
allow_failure: true
services:
- docker:stable-dind
before_script:
- docker info
script:
- docker pull codeclimate/codeclimate
- docker run --env CODECLIMATE_CODE="$PWD" --volume "$PWD":/code --volume /var/run/docker.sock:/var/run/docker.sock --volume /tmp/cc:/tmp/cc codeclimate/codeclimate analyze -f json > codeclimate.json
artifacts:
paths: [codeclimate.json]
security_advisories:
stage: test
script:
# Run the SensioLabs security advisory checker. See security.sensiolabs.org.
- security-checker security:check composer.lock
build:
stage: build
# this tells the build server to save these files between jobs, this keeps them to be deployed
artifacts:
paths:
- bin
- vendor
- web
script:
# Run Composer to build site (use --no-dev for production builds).
- composer install --no-interaction
# Remove the node_modules dir to rebuld/reinstall new versions.
- rm -rf node_modules
# Compile Sass from theme using npm defined in our package.
- cd web/themes/custom/commerce_2_demo
- npm install
- ./node_modules/gulp/bin/gulp.js sass
# Deploy base demo to STAGING site (AWS1).
base-demo-to-uat:
stage: deploy
# add any other tags or branches you want here
only:
- UAT
tags:
- Deploy
environment:
name: uat
url: https://commerce-2-demo.aws1.acrobuild.com
script:
# Install ssh-agent if not already installed, it is required by Docker
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
# Run ssh-agent (inside the build environment)
- eval $(ssh-agent -s)
# Add the SSH key stored in SSH_PRIVATE_KEY variable to the agent store
- ssh-add <(echo "$DEPLOY_KEY_UAT")
# Add the fingerprint for the host to known hosts so we can verify it.
# To determine the fingerprint of a host, use `ssh-keyscan -H`.
- mkdir -p ~/.ssh
- echo "$UAT_FINGERPRINT" >> ~/.ssh/known_hosts
# Download configuration files and sync changes with deployment server, excluding .git since it's not needed.
- git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@git.acromedia.com/teams/marketing/urban-hipster/urban-hipster-config.git dumps
- rsync -av --no-perms --no-owner --no-group --exclude-from '.gitlabci-rsync-exclude.txt' --exclude '.git' --delete ./ [email protected]:/home/commerce-2-demo/www/commerce-2-demo/
# log into the site, reset settings.php permissions and run scripts.
# IMPORTANT: Drupal 8.4 and Drush need PHP 7.1 but server defaults to 7.0. Need script to check PHP version and use the right one.
- ssh [email protected] 'chown commerce-2-demo:commerce-2-d-srv /home/commerce-2-demo/www/commerce-2-demo/web/sites/default/settings.php && /bin/bash -u -e -s commerce-2-demo demo' < ./scripts/remote-drush-commands_deploy.sh
# Deploy plus demo to STAGING site (AWS1).
plus-demo-to-uat:
stage: deploy
# add any other tags or branches you want here
only:
- UAT
tags:
- Deploy
environment:
name: uat
url: https://commerceplus.aws1.acrobuild.com
script:
# Install ssh-agent if not already installed, it is required by Docker
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
# Run ssh-agent (inside the build environment)
- eval $(ssh-agent -s)
# Add the SSH key stored in SSH_PRIVATE_KEY variable to the agent store
- ssh-add <(echo "$DEPLOY_KEY_UAT")
# Add the fingerprint for the host to known hosts so we can verify it.
# To determine the fingerprint of a host, use `ssh-keyscan -H`.
- mkdir -p ~/.ssh
- echo "$UAT_FINGERPRINT" >> ~/.ssh/known_hosts
# Download configuration files and sync changes with deployment server, excluding .git since it's not needed.
- git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@git.acromedia.com/teams/marketing/urban-hipster/urban-hipster-config.git dumps
- rsync -av --no-perms --no-owner --no-group --exclude-from '.gitlabci-rsync-exclude.txt' --exclude '.git' --delete ./ [email protected]:/home/commerce-2-demo/www/commerceplus/
# log into the site, reset settings.php permissions and run scripts.
# IMPORTANT: Drupal 8.4 and Drush need PHP 7.1 but server defaults to 7.0. Need script to check PHP version and use the right one.
- ssh [email protected] 'chown commerce-2-demo:commerce-2-dem-commerceplus-srv /home/commerce-2-demo/www/commerceplus/web/sites/default/settings.php && /bin/bash -u -e -s commerceplus demoplus' < ./scripts/remote-drush-commands_deploy.sh
# Deploy base demo to LIVE site (CLOUD4).
base-demo-to-live:
stage: deploy
# add any other tags or branches you want here
# NOTE: Master is also pushed to public accessible GitHub repo: https://github.com/AcroMedia/commerce-demo
only:
- master
tags:
- DeployProduction
environment:
name: cloud4
url: https://commercedemo.acromedia.com
script:
# Install ssh-agent if not already installed, it is required by Docker
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
# Run ssh-agent (inside the build environment)
- eval $(ssh-agent -s)
# Add the SSH key stored in SSH_PRIVATE_KEY variable to the agent store
- ssh-add <(echo "$DEPLOY_KEY_PRODUCTION_CLOUD4")
# Add the fingerprint for the host to known hosts so we can verify it.
# To determine the fingerprint of a host, use `ssh-keyscan -H`.
- mkdir -p ~/.ssh
- echo "$PRODUCTION_FINGERPRINT_CLOUD4" >> ~/.ssh/known_hosts
# Download configuration files and sync changes with deployment server, excluding .git since it's not needed.
- git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@git.acromedia.com/teams/marketing/urban-hipster/urban-hipster-config.git dumps
- rsync -av --no-perms --no-owner --no-group --exclude-from '.gitlabci-rsync-exclude.txt' --exclude '.git' --delete ./ [email protected]:/home/drupalcommerce/www/demo/
# log into the site, reset settings.php permissions and run scripts.
# IMPORTANT: Drupal 8.4 and Drush need PHP 7.1 but server defaults to 7.0. Need script to check PHP version and use the right one.
- ssh [email protected] 'chown drupalcommerce:drupalcommerce-demo-srv /home/drupalcommerce/www/demo/web/sites/default/settings.php && /bin/bash -u -e -s demo demo' < ./scripts/remote-drush-commands_deploy.sh
# Deploy plus demo to LIVE site (CLOUD4).
plus-demo-to-live:
stage: deploy
# add any other tags or branches you want here.
# NOTE: Master is also pushed to public accessible GitHub repo: https://github.com/AcroMedia/commerce-demo
only:
- master
tags:
- DeployProduction
environment:
name: cloud4.acromedia.com
url: https://demoplus.cloud4.acromedia.com
script:
# Install ssh-agent if not already installed, it is required by Docker
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
# Run ssh-agent (inside the build environment)
- eval $(ssh-agent -s)
# Add the SSH key stored in SSH_PRIVATE_KEY variable to the agent store
- ssh-add <(echo "$DEPLOY_KEY_PRODUCTION_CLOUD4")
# Add the fingerprint for the host to known hosts so we can verify it.
# To determine the fingerprint of a host, use `ssh-keyscan -H`.
- mkdir -p ~/.ssh
- echo "$PRODUCTION_FINGERPRINT_CLOUD4" >> ~/.ssh/known_hosts
# Download configuration files and sync changes with deployment server, excluding .git since it's not needed.
- git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@git.acromedia.com/teams/marketing/urban-hipster/urban-hipster-config.git dumps
- rsync -avq --no-perms --no-owner --no-group --exclude-from '.gitlabci-rsync-exclude.txt' --exclude '.git' --delete ./ [email protected]:/home/drupalcommerce/www/demoplus/
# log into the site, reset settings.php permissions and run scripts.
# IMPORTANT: Drupal 8.4 and Drush need PHP 7.1 but server defaults to 7.0. Need script to check PHP version and use the right one.
- ssh [email protected] 'chown drupalcommerce:drupalcommerce-demoplus-srv /home/drupalcommerce/www/demoplus/web/sites/default/settings.php && /bin/bash -u -e -s demoplus demoplus' < ./scripts/remote-drush-commands_deploy.sh
# Deploy plus demo to LIVE site (AWS).
plus-demo-to-live-AWS:
stage: deploy
# add any other tags or branches you want here.
# NOTE: Master is also pushed to public accessible GitHub repo: https://github.com/AcroMedia/commerce-demo
only:
- performance_update
tags:
- DeployProduction
environment:
name: commerceplus-new.acromedia.com
url: https://commerceplus-front.acromedia.com
script:
# Install ssh-agent if not already installed, it is required by Docker
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
# Run ssh-agent (inside the build environment)
- eval $(ssh-agent -s)
# Add the SSH key stored in SSH_PRIVATE_KEY variable to the agent store
- ssh-add <(echo "$DEPLOY_KEY_PRODUCTION_AWS")
# Add the fingerprint for the host to known hosts so we can verify it.
# To determine the fingerprint of a host, use `ssh-keyscan -H`.
- mkdir -p ~/.ssh
- echo "$PRODUCTION_FINGERPRINT_AWS" >> ~/.ssh/known_hosts
# Download configuration files and sync changes with deployment server, excluding .git since it's not needed.
- git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@git.acromedia.com/teams/marketing/urban-hipster/urban-hipster-config.git dumps
- rsync -avq --no-perms --no-owner --no-group --exclude-from '.gitlabci-rsync-exclude.txt' --exclude '.git' --delete ./ [email protected]:/home/acro/www/cpback/
# log into the site, reset settings.php permissions and run scripts.
# IMPORTANT: Drupal 8.4 and Drush need PHP 7.1 but server defaults to 7.0. Need script to check PHP version and use the right one.
- ssh [email protected] 'chown acro:acro-cpback-srv /home/acro/www/cpback/web/sites/default/settings.php && /bin/bash -u -e -s cpback demoplus' < ./scripts/remote-drush-commands_deploy.sh
plus-demo-live-post:
image: smmccabe/docker
stage: post
only:
- UAT
- master
- performance_update
dependencies:
- plus-demo-to-live
script:
# Test initial page load.
- commercebot --headless --url https://commerceplus.acromedia.com --timer-only 5000
# Test flows as well.
- commercebot --headless --url https://commerceplus.acromedia.com