-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
66 lines (60 loc) · 2.05 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
image: docker:stable
services:
- docker:dind
stages:
- test
- push
- deploy
before_script:
- docker info
- apk update
test:
image: python:3.6.8-alpine3.9
stage: test
before_script:
- apk add --no-cache --virtual .build-deps gcc python3-dev musl-dev postgresql-dev jpeg-dev zlib-dev
- pip install toolz
- pip install -r requirements.txt
script:
- pycodestyle --exclude='manage.py, patient-management/settings.py, patient-management/gitlab-ci-settings.py, */tests.py, */migrations' .
- python3 manage.py makemigrations --settings=patient-management.gitlab-ci-settings
- python3 manage.py migrate --settings=patient-management.gitlab-ci-settings
- pytest --ds=patient-management.gitlab-ci-settings --cov=core --cov=users --cov=consultations --disable-warnings
push to github:
stage: push
before_script:
- apk add --quiet --no-cache git
- 'which ssh-agent || ( apk add openssh-client )'
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
- git config --global user.name "$GITLAB_USER_ID"
- git config --global user.email "$GITLAB_USER_EMAIL"
- git remote set-url origin [email protected]:pi2-fga/201901-TriagemHospitalar-PatientManagement.git
script:
- git checkout $CI_COMMIT_REF_NAME
- git push origin $CI_COMMIT_REF_NAME --force
deploy production:
stage: deploy
variables:
IMAGE_TAG: master
before_script:
- apk add --quiet --no-cache py-pip
- pip install --quiet docker-compose==1.23.2
- docker login registry.gitlab.com --username gitlab-ci-token --password $CI_BUILD_TOKEN
script:
- docker-compose -f docker-compose.production.yml pull
- docker-compose -f docker-compose.production.yml build
- docker-compose -f docker-compose.production.yml push
environment:
name: production
only:
- /^master$/
except:
variables:
- $CI_COMMIT_MESSAGE =~ /skip-deploy/
tags:
- docker