-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.gitlab-ci.yml
183 lines (168 loc) · 4.55 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
stages:
- build
- test
- notify
- deploy
- cypress
- deploy_uat
.deploy_job: &deploy_job
image: intractosre/deploy:1
stage: deploy
tags:
- aws
before_script:
- eval $(ssh-agent -s)
- echo "$DEPLOYMENT_SSH_KEY" | tr -d '\r' | ssh-add - > /dev/null
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- ssh-keyscan -t rsa -p $SSH_PORT $HOST >> ~/.ssh/known_hosts
script:
- rsync -e "ssh -p $SSH_PORT" -avuz --no-perms --omit-dir-times --exclude-from=.rsyncignore --delete --delete-after $CI_PROJECT_DIR/ $PROJECT_USER@$HOST:$PROJECT_DIR
- >
ssh -p $SSH_PORT $PROJECT_USER@$HOST "source /.victhorious/conf/shell/envvars && cd $PROJECT_DIR &&
ln -sf ../../lib/modules $PROJECT_DIR/web/modules/custom &&
ln -sf ../../lib/themes $PROJECT_DIR/web/themes/custom &&
ln -sf ../../lib/profiles $PROJECT_DIR/web/profiles/custom &&
ln -sf $PROJECT_DIR/web $PROJECT_DIR/web/community &&
chown -R $PROJECT_USER:$PROJECT_GROUP $PROJECT_DIR &&
./vendor/bin/drush updb -y &&
./vendor/bin/drush cr &&
./vendor/bin/drush cim -y &&
./vendor/bin/drush cr"
.rollback_trigger_updb: &rollback_trigger_updb
image: intractosre/deploy:1
stage: deploy
when: manual
tags:
- aws
before_script:
- eval $(ssh-agent -s)
- echo "$DEPLOYMENT_SSH_KEY" | tr -d '\r' | ssh-add - > /dev/null
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- ssh-keyscan -t rsa -p $SSH_PORT $HOST >> ~/.ssh/known_hosts
script:
- >
ssh -p $SSH_PORT $PROJECT_USER@$HOST "source /.victhorious/conf/shell/envvars && cd $PROJECT_DIR &&
./vendor/bin/drush php-eval \"echo drupal_set_installed_schema_version('eic_deploy', $UPDB_VERSION);\" &&
./vendor/bin/drush updb -y &&
./vendor/bin/drush cim -y &&
./vendor/bin/drush cr"
build_backend:
stage: build
image: public.ecr.aws/h5g0v9w1/php-fpm:7.4
artifacts:
untracked: true
expire_in: '2 hour'
script:
- composer --no-ansi --no-interaction install --no-progress --prefer-dist --optimize-autoloader
# Gitlab CI will exclude any directory containing a .git folder from artifacts, remove it temporarily
- find $CI_PROJECT_DIR/web/modules/contrib -type d -name ".git" -exec rm -rf {} +
- find $CI_PROJECT_DIR/vendor -type d -name ".git" -exec rm -rf {} +
only:
- /^release/.*$/
- develop
build_front:
stage: build
image: node:14
artifacts:
untracked: true
expire_in: '2 hour'
script:
- cd lib/themes/eic_community
- npm install && npm run build && npm run react-production
- npm run pregenerate-storybook && npm run generate-storybook && npm run postgenerate-storybook
- cd node_modules && find . -mindepth 1 -maxdepth 1 -type d ! -name "@ecl*" -exec rm -rf {} +
only:
- /^release/.*$/
- develop
security_check:
stage: test
image: jakzal/phpqa:php7.4
script:
- local-php-security-checker
only:
- develop
- /^release/.*$/
sbom_send:
image: public.ecr.aws/io-brussels/sbom-collector
artifacts:
paths:
- $CI_PROJECT_DIR/bom.xml
expire_in: 2 hours
script:
- cd $CI_PROJECT_DIR && composer -n make-bom --output-file=$CI_PROJECT_DIR/bom.xml
- cat $CI_PROJECT_DIR/bom.xml | send_bom
only:
- develop
- /^release/.*$/
deploy_develop:
<<: *deploy_job
stage: deploy
variables:
HOST: $DEVELOP_HOST
only:
- develop
deploy_qa:
<<: *deploy_job
stage: deploy
variables:
HOST: $QA_HOST
only:
- /^release/.*$/
deploy_uat:
<<: *deploy_job
stage: deploy_uat
when: manual
variables:
HOST: $UAT_HOST
only:
- /^release/.*$/
deploy_migration_env:
<<: *deploy_job
stage: deploy_uat
when: manual
variables:
HOST: $MIGRATION_HOST
only:
- /^release/.*$/
rollback_trigger_updb_develop:
<<: *rollback_trigger_updb
variables:
HOST: $DEVELOP_HOST
only:
- develop
rollback_trigger_updb_qa:
<<: *rollback_trigger_updb
variables:
HOST: $QA_HOST
only:
- /^release/.*$/
rollback_trigger_updb_uat:
<<: *rollback_trigger_updb
variables:
HOST: $UAT_HOST
only:
- /^release/.*$/
slack_notifier:
stage: notify
image: curlimages/curl:latest
script:
- |
curl -X POST $SLACK_URL -H 'Content-Type: application/json' -d '{"text": "New deployment running on QA. Environment will be updated in a few minutes..."}'
only:
- /^release/.*$/
cypress_test_qa:
stage: cypress
image: cypress/base:10
allow_failure: true
artifacts:
when: always
untracked: true
expire_in: '2 hour'
script:
- cd e2e
- npm install
- npx cypress run
only:
- /^release/.*$/