-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathhtml-dynamic-env.yml
81 lines (79 loc) · 2.71 KB
/
html-dynamic-env.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
---
variables:
BUILD_DIRECTORY: "build"
start_env:
tags:
- docker
- miquido
image: docker/compose:alpine-1.29.2
stage: start_dynamic_env
before_script:
- apk add --no-cache openssh
- |
docker context create miquido-internal \
--description "Internal miquido docker at docker.miquido.net" \
--docker "host=ssh://docker.miquido.net"
- docker version
- docker-compose version
script:
- |
cat <<EOT >> env.conf
server {
listen 80;
root /var/www/$CI_PROJECT_NAME-$CI_COMMIT_REF_SLUG;
index index.html index.htm;
server_name $CI_PROJECT_NAME-$CI_COMMIT_REF_SLUG.gitlab.d.miquido.net;
location / {
try_files \$uri \$uri/ /index.html;
}
}
EOT
- \[ ! -d "$BUILD_DIRECTORY" \] && echo "Missing $BUILD_DIRECTORY directory. Exiting" && exit 1
- |
ssh [email protected] \
"rm -rf /docker/gitlab-dynamic-environments/sites/$CI_PROJECT_NAME-$CI_COMMIT_REF_SLUG"
- |
scp -r $BUILD_DIRECTORY \
[email protected]:/docker/gitlab-dynamic-environments/sites/$CI_PROJECT_NAME-$CI_COMMIT_REF_SLUG
- scp env.conf [email protected]:/docker/gitlab-dynamic-environments/nginx-config/$CI_PROJECT_NAME-$CI_COMMIT_REF_SLUG.conf # yamllint disable-line rule:line-length
- docker context use miquido-internal
- docker exec gitlab-dynamic-env_nginx_1 /etc/init.d/nginx reload
environment:
name: review/$CI_COMMIT_REF_SLUG
url: "https://$CI_PROJECT_NAME-$CI_COMMIT_REF_SLUG.gitlab.d.miquido.net"
on_stop: stop_review
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
stop_review:
tags:
- docker
- miquido
image: docker/compose:alpine-1.29.2
stage: stop_dynamic_env
before_script:
- apk add --no-cache openssh
- |
docker context create miquido-internal \
--description "Internal miquido docker at docker.miquido.net" \
--docker "host=ssh://docker.miquido.net"
- docker version
- docker-compose version
script:
# yamllint disable rule:line-length
- |
ssh [email protected] \
"rm -rf /docker/gitlab-dynamic-environments/sites/$CI_PROJECT_NAME-$CI_COMMIT_REF_SLUG"
- |
ssh [email protected] \
"rm -rf /docker/gitlab-dynamic-environments/nginx-config/$CI_PROJECT_NAME-$CI_COMMIT_REF_SLUG.conf"
# yamllint enable rule:line-length
- docker context use miquido-internal
- docker exec gitlab-dynamic-env_nginx_1 /etc/init.d/nginx reload
dependencies: []
environment:
name: review/$CI_COMMIT_REF_SLUG
action: stop
allow_failure: true
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
when: manual