This repository has been archived by the owner on Jun 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
.gitlab-ci.yml
57 lines (50 loc) · 1.63 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
stages:
- test # run the tests for this codebase
- build # build the container image and push it to the container registry
- deploy # deploy the built image on Kubernetes
variables:
# define the base images to use in the stages
REGISTRY_BASE_IMAGES: sre/base-images
BASE_IMAGE_TAG: go-1.13-v0.0.2
BUILD_IMAGE: $REGISTRY_URL/$REGISTRY_BASE_IMAGES:$BASE_IMAGE_TAG
# the replicant REGISTRY repository URLs
REPLICANT_REGISTRY_URL: $REGISTRY_URL/sre/replicant
# we should run the tests on all merge requests and master
test:
stage: test
image: $BUILD_IMAGE
only:
- external_pull_requests
- master
script:
- make test
build_and_push_pr:
stage: build
image: docker
only:
- external_pull_requests
before_script:
- apk update
- apk add py2-pip git
- pip install awscli
- eval $($REGISTRY_LOGIN) &>/dev/null
script:
- docker build -f Dockerfile . -t $REPLICANT_REGISTRY_URL:$CI_COMMIT_SHA
- docker push $REPLICANT_REGISTRY_URL:$CI_COMMIT_SHA
push_tag_registry:
stage: build
image: docker
only:
- tags
before_script:
- apk update
- apk add py2-pip git
- pip install awscli
- eval $($REGISTRY_LOGIN) &>/dev/null
- git pull origin master --tags --force
- export GIT_TAG=`git tag --sort=-version:refname | egrep -m 1 "v[0-9]+\.[0-9]+\.[0-9]+"`
script:
- docker build -f Dockerfile . -t $REPLICANT_REGISTRY_URL:latest -t $REPLICANT_REGISTRY_URL:$CI_COMMIT_SHA -t $REPLICANT_REGISTRY_URL:$GIT_TAG
- docker push $REPLICANT_REGISTRY_URL:latest
- docker push $REPLICANT_REGISTRY_URL:$CI_COMMIT_SHA
- docker push $REPLICANT_REGISTRY_URL:$GIT_TAG