-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.yml
96 lines (89 loc) · 3.25 KB
/
config.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
89
90
91
92
93
94
95
96
version: 2.1
jobs:
build-and-test:
docker:
- image: cimg/python:3.10.2
resource_class: small
steps:
- checkout
- restore_cache:
key: deps1-{{ .Branch }}-{{ checksum "requirements.txt" }}
- run:
name: Initialize venv / Install deps
command: |
python -m venv venv
. venv/bin/activate
pip install -r requirements.txt
- save_cache:
key: deps1-{{ .Branch }}-{{ checksum "requirements.txt" }}
paths:
- ".venv"
- run:
name: Linting
command: |
. venv/bin/activate
flake8
- run:
name: Run tests
command: |
. venv/bin/activate
pytest
containerize:
docker:
- image: cimg/python:3.10.2
resource_class: medium
steps:
- checkout
- setup_remote_docker
- run:
name: Containerize
command: |
echo "$DOCKER_PASSWORD" | docker login --username $DOCKER_LOGIN --password-stdin
docker build -t image_oc_lettings_site .
docker tag image_oc_lettings_site $DOCKER_LOGIN/$DOCKER_REPO:$CIRCLE_SHA1
docker push $DOCKER_LOGIN/$DOCKER_REPO:$CIRCLE_SHA1
deploy:
# Add ONE of these command lines to the pipeline depending on whether you want to :
# - create an app with Postgresql addon (if app does not exist, recommended for first deploy)
# HEROKU_API_KEY=${HEROKU_TOKEN} heroku apps:create $HEROKU_APP_NAME --region eu --addons=heroku-postgresql
# - create Postgresql addon for existing app
# HEROKU_API_KEY=${HEROKU_TOKEN} heroku addons:create heroku-postgresql -a $HEROKU_APP_NAME --confirm $HEROKU_APP_NAME
# !! Leave empty if app with Postresql addon already exists !!
# !! Please remove added line for future commits !!
machine:
image: ubuntu-2004:current
resource_class: medium
steps:
- checkout
- run:
name: Deploy Docker image to Heroku
command: |
sudo curl https://cli-assets.heroku.com/install.sh | sh
HEROKU_API_KEY=${HEROKU_TOKEN} heroku container:login
# (paste command line here)
HEROKU_API_KEY=${HEROKU_TOKEN} heroku config:set DJANGO_SECRET_KEY=$DJANGO_SECRET_KEY -a $HEROKU_APP_NAME
HEROKU_API_KEY=${HEROKU_TOKEN} heroku config:set SENTRY_DSN=$SENTRY_DSN -a $HEROKU_APP_NAME
HEROKU_API_KEY=${HEROKU_TOKEN} heroku config:set DEBUG=0 -a $HEROKU_APP_NAME
HEROKU_API_KEY=${HEROKU_TOKEN} heroku container:push -a $HEROKU_APP_NAME web
HEROKU_API_KEY=${HEROKU_TOKEN} heroku container:release -a $HEROKU_APP_NAME web
HEROKU_API_KEY=${HEROKU_TOKEN} heroku run python manage.py migrate -a $HEROKU_APP_NAME
HEROKU_API_KEY=${HEROKU_TOKEN} heroku run python manage.py loaddata data.json -a $HEROKU_APP_NAME
workflows:
main:
jobs:
- build-and-test
- containerize:
requires:
- build-and-test
filters:
branches:
only:
- master
- deploy:
requires:
- build-and-test
- containerize
filters:
branches:
only:
- master