This repository has been archived by the owner on Oct 21, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
83 lines (76 loc) · 2.11 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
image: 'registry.magic-technik.de/gitlab-ci/alpine-deploy:latest'
stages:
- test_build
- build
- tag_qa
- deploy_qa
- tag
- deploy
before_script:
- if [ "${CI_BUILD_REF_NAME}" == "master" ];then export TARGET_ENV="int"; else export TARGET_ENV=${CI_BUILD_REF_NAME}; fi
- export AWS_ACCOUNT_ID=$(eval echo \$${TARGET_ENV}_ACCOUNT_ID)
- export AWS_ACCESS_KEY_ID=$(eval echo \$${TARGET_ENV}_ACCESS_KEY)
- export AWS_SECRET_ACCESS_KEY=$(eval echo \$${TARGET_ENV}_SECRET_KEY)
- export ECR_REPO=${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/${SERVICE}
- export TAG=${CI_BUILD_REF}
- export RACK_ENV=production
test_build_service:
stage: test_build
only:
- master
script:
- docker build --build-arg BUILD_ID=${CI_BUILD_ID} --build-arg BUILD_COMMIT=${TAG} --tag=${IMAGE}:${TAG} -f Dockerfile .
- (sleep 5; docker stop test-${SERVICE}) &
- docker run --rm=true --name=test-${SERVICE} -e "RELEASES_FILE=${RELEASES_FILE}" ${IMAGE}:${TAG}
- docker push ${IMAGE}:${TAG}
tags:
- ptv
# Rancher
push_qa:
stage: tag_qa
only:
- master
script:
- docker pull ${IMAGE}:${TAG}
- docker tag ${IMAGE}:${TAG} ${IMAGE}:qa
- docker push ${IMAGE}:qa
tags:
- ptv
deploy_qa:
stage: deploy_qa
only:
- master
script:
- cd deploy
- rancher-compose -p ${SERVICE}-${CI_BUILD_REF_NAME} up -d --upgrade --pull --force-upgrade --batch-size 1
- rancher-compose -p ${SERVICE}-${CI_BUILD_REF_NAME} up -d --confirm-upgrade
tags:
- ptv
# ECS
tag_ecs:
stage: tag
only:
- master
- sta
- lve
script:
- eval $(aws ecr get-login)
- docker pull ${IMAGE}:${TAG}
- docker tag -f ${IMAGE}:${TAG} ${IMAGE}:latest
- docker tag -f ${IMAGE}:${TAG} ${ECR_REPO}:${TAG}
- docker tag -f ${IMAGE}:${TAG} ${ECR_REPO}:latest
- docker push ${IMAGE}:latest
- docker push ${ECR_REPO}:${TAG}
- docker push ${ECR_REPO}:latest
tags:
- ptv
deploy_ecs:
stage: deploy
only:
- master
- sta
- lve
script:
- ecs-deploy -t 120 --cluster ${ECS_CLUSTER} --service-name ${SERVICE} --image ${ECR_REPO}:latest
tags:
- ptv