-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path.gitlab-ci.yml
76 lines (67 loc) · 2.12 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
image: docker.gitlab.blep.cz/blep.cz/pipenv-runner
include:
- template: Dependency-Scanning.gitlab-ci.yml
- template: License-Scanning.gitlab-ci.yml
- template: SAST.gitlab-ci.yml
stages:
- lint
- test
- deploy
.base_job:
before_script:
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
- chmod 600 ~/.ssh/known_hosts
variables:
PIP_REQUIREMENTS_FILE: pos/requirements.txt
SAST_DEFAULT_ANALYZERS: "bandit,eslint,secrets"
license_scanning:
variables:
LICENSE_FINDER_CLI_OPTS: --pip-requirements-path=pos/requirements.txt
pylint:
stage: lint
script:
- cd pos
- pip install -r requirements.txt
- pylint posapp --ignore posapp/migrations || pylint-exit $?
django:
extends: .base_job
stage: test
script:
- cd pos
- pip install -r requirements.txt
- python manage.py test
beta-server:
extends: .base_job
stage: deploy
script:
- echo "HOST=beta.puda.pos.beer" >> .env
- echo "TRAEFIK_NAME=pudapos-beta" >> .env
- sed -ie 's~^DEBUG=\(.*\)$~DEBUG=1~g' .env
- sed -ie 's~^DEFAULT_PAGE_TITLE=\(.*\)$~DEFAULT_PAGE_TITLE=PUDA POS Beta~g' .env
- tar -czf /tmp/backend.tar.gz .
- scp /tmp/backend.tar.gz [email protected]:~/beta/backend.tar.gz
- ssh [email protected] "bash ~/deploy_pudapos_beta.sh"
rules:
- if: '$CI_COMMIT_BRANCH == "master"'
when: on_success
test-server:
extends: .base_job
stage: deploy
script:
- echo "HOST=test.puda.pos.beer" >> .env
- echo "TRAEFIK_NAME=pudapos-test" >> .env
- sed -ie 's~^DEBUG=\(.*\)$~DEBUG=1~g' .env
- sed -ie 's~^VERSION=\(.*\)$~VERSION=\1-'"$CI_COMMIT_SHORT_SHA"'~g' .env
- sed -ie 's~^DEFAULT_PAGE_TITLE=\(.*\)$~DEFAULT_PAGE_TITLE=PUDA POS Test~g' .env
- tar -czf /tmp/backend.tar.gz .
- scp /tmp/backend.tar.gz [email protected]:~/test/backend.tar.gz
- ssh [email protected] "bash ~/deploy_pudapos_test.sh"
rules:
- if: '$CI_MERGE_REQUEST_IID'
when: never
- if: '$CI_COMMIT_BRANCH != "master"'
when: on_success