-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
75 lines (66 loc) · 1.66 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
image: docker:stable
stages:
- build
- deploy
- move_ns
- update
variables:
IMAGE_NAME: $CI_REGISTRY/scpomedialab/resin-annuaire
before_script:
- VERSION=$(echo $CI_COMMIT_TAG | sed -nre 's/^v?([0-9.]+)$/\1/p')
- if [ -n "${VERSION}" ]; then IMAGE_TAG=${VERSION}; else IMAGE_TAG=${CI_COMMIT_REF_SLUG}; fi
- export KUBECONFIG=$kubeconfig_file
build:
stage: build
script:
- docker build -t $IMAGE_NAME:$IMAGE_TAG -f ./Dockerfile .
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD"
- docker push $IMAGE_NAME:$IMAGE_TAG
environment:
name: $CI_COMMIT_REF_SLUG
only:
- tags
except:
- schedules
deploy:
image:
name: jrisp/kubehelper:latest
entrypoint: [""]
stage: deploy
script:
- echo "Deploying resin-sciencespo overlay..."
- cp ${RESIN_SECRETS} k8s/overlays/prod/sciencespo/secrets.env
- kubectl apply -f k8s/overlays/prod/sciencespo/ns.yml
- kubectl apply -k k8s/overlays/prod/sciencespo
environment:
name: $CI_COMMIT_REF_SLUG
only:
- prod
except:
- schedules
move_ns:
image:
name: rancher/cli2:v2.4.5
entrypoint: [""]
stage: move_ns
script:
- rancher login $RANCHER_URL --token $RANCHER_TOKEN --context $RANCHER_CONTEXT
- rancher namespaces move resin-sciencespo $RANCHER_CONTEXT
environment:
name: $CI_COMMIT_REF_SLUG
only:
- prod
except:
- schedules
update:
image:
name: jrisp/kubehelper:latest
entrypoint: [""]
stage: update
script:
- echo "Redeploying resin-sciencespo overlay..."
- kubectl -n resin-sciencespo rollout restart deployment frontend
environment:
name: $CI_COMMIT_REF_SLUG
only:
- schedules