-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
47 lines (41 loc) · 1.8 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
variables:
TELEGRAM_BOT_TOKEN: $TELEGRAM_BOT_TOKEN
TELEGRAM_CHAT_ID: $TELEGRAM_CHAT_ID
before_script:
- docker info
- docker compose --version
- cp /home/gitlab-runner/webadmin/env.* .
- cp /home/gitlab-runner/webadmin/*.pem ./backend/
tg_describe_pipeline:
script:
- 'curl -X POST -H "Content-Type: application/json" -d "{\"chat_id\": \"$TELEGRAM_CHAT_ID\", \"parse_mode\": \"Markdown\", \"text\": \"STARTING SITE DEPLOYMENT: commit $CI_COMMIT_SHA ($CI_COMMIT_DESCRIPTION) \"}" https://api.telegram.org/bot$TELEGRAM_BOT_TOKEN/sendMessage'
rules:
- if: $CI_COMMIT_BRANCH == "master"
when: always
- when: never
build_image:
script:
- docker-compose -f docker-compose.yml up -d --build
- 'curl -X POST -H "Content-Type: application/json" -d "{\"chat_id\": \"$TELEGRAM_CHAT_ID\", \"text\": \"DEPLOYMENT: 1: Builded image\"}" https://api.telegram.org/bot$TELEGRAM_BOT_TOKEN/sendMessage'
rules:
- if: $CI_COMMIT_BRANCH == "master"
when: always
- when: never
collect_static_files:
script:
- docker-compose exec -T web python manage.py collectstatic --no-input
- 'curl -X POST -H "Content-Type: application/json" -d "{\"chat_id\": \"$TELEGRAM_CHAT_ID\", \"text\": \"DEPLOYMENT: 2: Collected static\"}" https://api.telegram.org/bot$TELEGRAM_BOT_TOKEN/sendMessage'
rules:
- if: $CI_COMMIT_BRANCH == "master"
when: always
- when: never
migrate_database:
script:
- docker-compose exec -T web python manage.py migrate --no-input
- 'curl -X POST -H "Content-Type: application/json" -d "{\"chat_id\": \"$TELEGRAM_CHAT_ID\", \"text\": \"DEPLOYMENT: 3: Migrated database\"}" https://api.telegram.org/bot$TELEGRAM_BOT_TOKEN/sendMessage'
rules:
- if: $CI_COMMIT_BRANCH == "master"
when: always
- when: never
after_script:
- docker container ls