-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
68 lines (59 loc) · 1.38 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
variables:
IMAGE_TAG: $GLOBAL_REGISTRY/$CI_PROJECT_PATH_SLUG:$CI_COMMIT_REF_SLUG-$CI_PIPELINE_IID
stages:
- build
- deploy
.dev: &dev_configuration
environment: development
only:
- develop
variables:
INVENTORY: deploy/ansible/inventory/development
VARS_FILE: ./vars/development.yml
.prod: &prod_configuration
environment: production
only:
- main
variables:
INVENTORY: deploy/ansible/inventory/production
VARS_FILE: ./vars/production.yml
.build:
stage: build
tags:
- vvdev
before_script:
- docker login --username oauth --password $GLOBAL_DOCKER_OAUTH cr.yandex
script:
- docker build -t $IMAGE_TAG -f deploy/build.dockerfile .
after_script:
- docker push $IMAGE_TAG
.deploy:
stage: deploy
image: volgavolga/ansible:1.0.0
tags:
- vvdev
script:
- echo "$GLOBAL_RUNNER_SSH_KEY" > deploy_rsa
- chmod 400 deploy_rsa
- ansible-playbook deploy/ansible/main.yml
-i $INVENTORY
--private-key deploy_rsa
--extra-vars "VARS_FILE=$VARS_FILE"
--extra-vars "APP_ENV=\"$APP_ENV\""
--extra-vars "IMAGE_TAG=$IMAGE_TAG"
# DEVELOPMENT
build:dev:
<<: *dev_configuration
stage: build
extends: .build
deploy:dev:
<<: *dev_configuration
extends: .deploy
# PRODUCTION
build:prod:
<<: *prod_configuration
stage: build
extends: .build
deploy:prod:
<<: *prod_configuration
extends: .deploy