-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
94 lines (83 loc) · 2.09 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
stages:
- build
- deploy-test
- deploy-prod
variables:
DOCKER_IMAGE: ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHORT_SHA}
DOCKER_TLS_CERTDIR: ""
.branch-rules-main:
rules:
- if: $CI_DEPLOY_FREEZE == null && $CI_COMMIT_BRANCH == "main"
when: on_success
.branch-rules-review:
extends: .branch-rules-main
rules:
- if: $CI_DEPLOY_FREEZE == null && $CI_COMMIT_BRANCH != "main"
when: on_success
#Base templates
.deploy:
image: dockerhub.ebi.ac.uk/ensembl-web/deploy-tools:latest
before_script:
- kubectl config use-context ${AGENT}
- kubectl config set-context --current --namespace=${NS}
script:
- git clone --depth 1 --branch k8s123-migration https://gitlab.ebi.ac.uk/ensembl-web/ensembl-k8s-manifests.git
- cd ensembl-k8s-manifests/ensembl-web-track-api
- kustomize edit set image DOCKER_IMAGE=${DOCKER_IMAGE}
- kubectl apply -k .
.deploy-main:
extends:
- .deploy
- .branch-rules-main
.deploy-review:
extends:
- .deploy
- .branch-rules-review
#Build docker image
Docker:
stage: build
image: docker
services:
- docker:dind
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
script:
- docker build -t ${DOCKER_IMAGE} --no-cache -f Dockerfile .
- docker push ${DOCKER_IMAGE}
- docker rmi ${DOCKER_IMAGE}
- docker logout $CI_REGISTRY
#Deploy to k8s
Prod:
stage: deploy-prod
extends: .deploy-main
environment:
name: production
when: manual
variables:
AGENT: ${PROD_AGENT}
NS: ${PROD_NS}
Fallback:
stage: deploy-prod
extends: .deploy-main
environment:
name: fallback
when: manual
variables:
AGENT: ${FALLBACK_AGENT}
NS: ${FALLBACK_NS}
Staging:
stage: deploy-test
extends: .deploy-main
environment:
name: staging
variables:
AGENT: ${STAGING_AGENT}
NS: ${STAGING_NS}
Dev:
stage: deploy-test
extends: .deploy-review
environment:
name: development
variables:
AGENT: ${DEV_AGENT}
NS: ${DEV_NS}