-
Notifications
You must be signed in to change notification settings - Fork 23
/
.gitlab-ci.yml
80 lines (76 loc) · 2.48 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
stages:
- test
- build
test:
stage: test
image: freetechsolutions/python-flake8:231206.01
services:
- name: freetechsolutions/omlpgsql:develop
alias: plpython
- redis
cache:
paths:
- /root/.cache/pip/
- /usr/lib/python3.9/site-packages/
before_script:
- mkdir -p /opt/omnileads/ominicontacto/
- mkdir -p /opt/omnileads/static
- mkdir -p /opt/omnileads/media_root
- pip install -r requirements/requirements.txt
variables:
POSTGRES_DB: omnileads
POSTGRES_USER: omnileads
POSTGRES_PASSWORD: omnileadsrw
DATABASE_URL: "postgresql://postgres:postgres@postgres:5432/$POSTGRES_DB"
DJANGO_SETTINGS_MODULE: "ominicontacto.settings.gitlab"
script:
- bash check-js.sh
- flake8
- python manage.py test --failfast
- python manage.py compilemessages
rules:
- if: '$CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "develop"'
- if: '$RUN_TEST == "true"'
container-image:
services:
- docker:24.0.7-dind-alpine3.19
image: docker:24.0.7-alpine3.19
stage: build
before_script:
- apk add --no-cache docker-cli-buildx
script:
- >-
docker buildx build
--file=Dockerfile
--tag=dev
--target=dev
.
- >-
docker buildx build
--file=Dockerfile
--tag=run
--target=run
.
- |-
if [ -z "${DOCKER_USERNAME}" ] || [ -z "${DOCKER_SECRET}" ] || [ -z "${DOCKER_USER}" ] || [ -z "${DOCKER_PASSWORD}" ]; then
echo "Error: Una o más variables necesarias no están definidas."
exit 1
fi
if [ -z "$(cat .omnileads_version)" ]; then
echo "Error: El archivo .omnileads_version no existe o está vacío."
exit 1
fi
if [ "${CI_COMMIT_BRANCH}" == "master" ] || [[ "${CI_COMMIT_BRANCH}" == pre-release-* ]] || [[ "${CI_COMMIT_BRANCH}" == oml-2310-epica-WhatsApp ]]; then
echo "${DOCKER_SECRET}" | docker login --username "${DOCKER_USERNAME}" --password-stdin
IMAGE_VERSION=$(cat .omnileads_version)
docker tag run omnileads/omlapp:$IMAGE_VERSION
docker push docker.io/omnileads/omlapp:$IMAGE_VERSION
else
echo "${DOCKER_PASSWORD}" | docker login --username "${DOCKER_USER}" --password-stdin
IMAGE_VERSION=$(cat .omnileads_version)
docker tag run freetechsolutions/omlapp:$IMAGE_VERSION
docker push docker.io/freetechsolutions/omlapp:$IMAGE_VERSION
fi
rules:
- if: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "master"
- if: $CI_PIPELINE_SOURCE == "web"