-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path.gitlab-ci.yml
116 lines (107 loc) · 3.54 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
variables:
URL_DOCKER_IGNORE: "https://gitlab.ebi.ac.uk/api/v4/projects/${COMMON_PROJECT_ID}/repository/files/.dockerignore/raw?ref=master&private_token=${GITLAB_USER_API_TOKEN}"
#https://gitlab.ebi.ac.uk/api/v4/projects/3377/repository/files/.dockerignore/raw?ref=master
URL_DEPLOY_SH: "https://gitlab.ebi.ac.uk/api/v4/projects/${COMMON_PROJECT_ID}/repository/files/deploy.sh/raw?ref=master&private_token=${GITLAB_USER_API_TOKEN}"
#https://gitlab.ebi.ac.uk/api/v4/projects/3377/repository/files/deploy.sh/raw?ref=master
URL_WP_CONFIG_TEMPLATE_yml: "https://gitlab.ebi.ac.uk/api/v4/projects/${COMMON_PROJECT_ID}/repository/files/wp-config-template.yml/raw?ref=master&private_token=${GITLAB_USER_API_TOKEN}"
#https://gitlab.ebi.ac.uk/api/v4/projects/3377/repository/files/wp-config-template.yml/raw?ref=master
BE_API: "https://wwwdev.ebi.ac.uk/ProtVar/api"
stages:
# - test
- build_static_assets
- build_docker_image
- deploy
workflow:
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
variables:
BE_API: "https://www.ebi.ac.uk/ProtVar/api"
- when: always # Run the pipeline in other cases
.js:
image: node:16.15.1
before_script:
- node --version
- npm --version
- yarn --version
- pwd
- ls
- yarn install
#test:
# stage: test
# script:
# - echo "skipping test for now";
build_static_assets:
only:
refs:
- master
- dev
- test
extends: .js
stage: build_static_assets
script:
- echo "REACT_APP_API_BASE_URL=${BE_API}" > .env.local
- yarn build
artifacts:
paths:
- build/
build_docker_image:
only:
refs:
- master
- dev
- test
stage: build_docker_image
image: docker:latest
tags:
- dind
services:
- docker:dind
before_script:
- wget -O .dockerignore "${URL_DOCKER_IGNORE}"
- echo "--no-cache --no-cookies was not used by wget"
script:
- echo "$CI_REGISTRY_PASSWORD" | docker login -u $CI_REGISTRY_USER $CI_REGISTRY --password-stdin
- docker --version
- CONTAINER_IMAGE=${CI_REGISTRY_IMAGE}:latest
- echo ${CONTAINER_IMAGE}
- docker build -t ${CONTAINER_IMAGE} --no-cache -f deploy/Dockerfile .
- docker image ls
- docker push ${CONTAINER_IMAGE}
- docker rmi ${CONTAINER_IMAGE}
- docker logout "$CI_REGISTRY"
.kubectl:
image: alpine
stage: deploy
before_script:
- apk add --no-cache curl git bash
- curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
- chmod +x ./kubectl
- mv ./kubectl /usr/local/bin/kubectl
- wget -O deploy.sh "${URL_DEPLOY_SH}"
- wget -O wp-config-template.yml "${URL_WP_CONFIG_TEMPLATE_yml}"
- echo "--no-cache --no-cookies was not used by wget"
- if [ ! -f deploy.sh ]; then echo "k8s deployment file is missing"; exit 1; fi
- if [ ! -f wp-config-template.yml ]; then echo "k8s config file is missing"; exit 1; fi
- chmod +x deploy.sh
dev-deploy:
extends: .kubectl
only:
refs:
- dev
script:
- ./deploy.sh HX protvar-fe protvar-dev deployment # data-center app_name namespace type-of-deployment
test-deploy:
extends: .kubectl
only:
refs:
- test
script:
- ./deploy.sh HX protvar-fe protvar-test deployment
prod-deploy:
extends: .kubectl
only:
refs:
- master
script:
- ./deploy.sh HX protvar-fe protvar deployment # fallback app_name namespace type-of-deployment
- ./deploy.sh HL protvar-fe protvar deployment # prod app_name namespace type-of-deployment