-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
69 lines (60 loc) · 1.99 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
stages:
- build
- test
- deploy
image: moreillon/tdd-dind
services:
- name: docker:19.03.12-dind
variables:
APPLICATION_NAME: whereabouts-display-board
CONTAINER_IMAGE: ${AWS_ECR_PUBLIC_URL}/${APPLICATION_NAME}
CONTAINER_IMAGE_TEST: ${CONTAINER_IMAGE}:test
CONTAINER_IMAGE_LATEST: ${CONTAINER_IMAGE}:latest
CONTAINER_IMAGE_TAGGED: ${CONTAINER_IMAGE}:${CI_COMMIT_SHORT_SHA}
K8S_NODEPORT_PORT: 30777
build:
stage: build
tags:
- dind
only:
- master
before_script:
# Registry login
- aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin ${AWS_ECR_PUBLIC_URL}
# Create repository in ECR if it does not exist yet
- >
aws ecr-public create-repository --region us-east-1 --repository-name ${APPLICATION_NAME}
|| echo "Repository might have already existed"
script:
- docker build -t ${CONTAINER_IMAGE_TEST} .
- docker push ${CONTAINER_IMAGE_TEST}
test:
stage: test
coverage: '/All files[^|]*\|[^|]*\s+([\d\.]+)/'
only:
- master
tags:
- dind
before_script:
# Registry login
- aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin ${AWS_ECR_PUBLIC_URL}
# Create repository in ECR if it does not exist yet
- >
aws ecr-public create-repository --region us-east-1 --repository-name ${APPLICATION_NAME}
|| echo "Repository might have already existed"
script:
- docker run --rm ${CONTAINER_IMAGE_TEST} npm run coverage
- docker tag ${CONTAINER_IMAGE_TEST} ${CONTAINER_IMAGE_LATEST}
- docker tag ${CONTAINER_IMAGE_TEST} ${CONTAINER_IMAGE_TAGGED}
- docker push ${CONTAINER_IMAGE_LATEST}
- docker push ${CONTAINER_IMAGE_TAGGED}
deploy:
stage: deploy
only:
- master
script:
- envsubst < kubernetes_manifest.yml | kubectl apply -f -
environment:
name: production
kubernetes:
namespace: ${KUBERNETES_NAMESPACE}