-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
88 lines (83 loc) · 2.61 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
84
85
86
87
88
build:
image: docker:dind
stage: build
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker build -f Dockerfile -t $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA .
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA
build-test:
image: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA
stage: test
script:
- pip install pytest pytest-cov pytest-django
- PATH=~/.local/bin:$PATH pytest -vv
.deploy: &deploy
before_script:
- mkdir -p ~/.ssh; echo "$CI_SSH_KEY" > ~/.ssh/id_ed25519; chmod 700 ~/.ssh; chmod 600 ~/.ssh/*
script:
- set -x
- export HOST=$(echo $CI_ENVIRONMENT_URL | sed s@^.*://@@)
- export PROTO=$(echo $CI_ENVIRONMENT_URL | sed s@:.*@@)
- export CI_PROJECT_SLUG=$(echo $CI_PROJECT_NAME | sed s@[/.]@-@g)
- export ANSIBLE_HOST_KEY_CHECKING=False
- export ANSIBLE_FORCE_COLOR=true
- bigsudo .
compose_django_build=
compose_django_image=$CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA
wait_grep=spawned.uWSGI.worker.1
$DEPLOY
deploy@$HOST
-vv
| tee deploy.log
- grep unreachable=0 deploy.log &> /dev/null
- grep failed=0 deploy.log &> /dev/null
# ephemeral branch deployment
review-deploy:
# image: yourlabs/ansible
# UNCOMMENT ABOVE AND REMOVE BELOW
image: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA
stage: test
environment:
name: test/$CI_COMMIT_REF_NAME
url: http://${CI_ENVIRONMENT_SLUG}.$CI_PROJECT_NAME.ci.yourlabs.io
variables:
DEPLOY: >
compose=docker-compose.yml,docker-compose.traefik.yml,docker-compose.maildev.yml
lifetime=86400
project=$CI_ENVIRONMENT_SLUG
except:
- tags
- master
<<: *deploy
# permanent branch deployment:
master-deploy:
# image: yourlabs/ansible
# UNCOMMENT ABOVE AND REMOVE BELOW
image: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA
stage: deploy
environment:
name: master
url: https://master.$CI_PROJECT_NAME.ci.yourlabs.io
variables:
DEPLOY: >
compose=docker-compose.yml,docker-compose.traefik.yml,docker-compose.persist.yml,docker-compose.maildev.yml
home=/home/$CI_PROJECT_NAME-$CI_ENVIRONMENT_NAME
only:
refs:
- master
<<: *deploy
# latest tagged release permanent deployment:
demo:
# image: yourlabs/ansible
# UNCOMMENT ABOVE AND REMOVE BELOW
image: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA
stage: deploy
environment:
name: demo
url: https://demo.$CI_PROJECT_NAME.ci.yourlabs.io
variables:
DEPLOY: >
compose=docker-compose.yml,docker-compose.traefik.yml,docker-compose.persist.yml
home=/home/$CI_PROJECT_NAME-$CI_ENVIRONMENT_NAME
only: [tags]
<<: *deploy