@@ -10,44 +10,39 @@ jobs:
1010 postgres :
1111 image : postgres:13.10
1212 env :
13- POSTGRES_USER : ${{ secrets.POSTGRES_USER }}
14- POSTGRES_PASSWORD : ${{ secrets.POSTGRES_PASSWORD }}
15- POSTGRES_DB : ${{ secrets.POSTGRES_DB }}
13+ POSTGRES_USER : django_user
14+ POSTGRES_PASSWORD : django_password
15+ POSTGRES_DB : django_db
1616 ports :
1717 - 5432:5432
1818 options : --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
19- env :
20- POSTGRES_USER : ${{ secrets.POSTGRES_USER }}
21- POSTGRES_PASSWORD : ${{ secrets.POSTGRES_PASSWORD }}
22- POSTGRES_DB : ${{ secrets.POSTGRES_DB }}
23- DB_HOST : 127.0.0.1
24- DB_PORT : 5432
25- DJANGO_SECRET_KEY : ${{ secrets.DJANGO_SECRET_KEY }}
26- DJANGO_DEBUG : ${{ secrets.DJANGO_DEBUG }}
27- DJANGO_ALLOWED_HOSTS : ${{ secrets.DJANGO_ALLOWED_HOSTS }}
2819 steps :
29- - uses : actions/checkout@v3
30- - name : Set up Python
31- uses : actions/setup-python@v4
32- with :
33- python-version : 3.12
34- - name : Install dependencies
35- run : |
36- python -m pip install --upgrade pip setuptools
37- pip install flake8==6.0.0 flake8-isort==6.0.0
38- pip install -r ./backend/requirements.txt
39- - name : Test with flake8 and django tests
40- run : |
41- python -m flake8 backend/
42- cd backend/
43- python manage.py test
20+ - uses : actions/checkout@v3
21+ - name : Set up Python
22+ uses : actions/setup-python@v4
23+ with :
24+ python-version : 3.12
25+ - name : Install dependencies
26+ run : |
27+ python -m pip install --upgrade pip setuptools
28+ pip install flake8==6.0.0 flake8-isort==6.0.0
29+ pip install -r ./backend/requirements.txt
30+ - name : Test with flake8 and django tests
31+ env :
32+ POSTGRES_USER : django_user
33+ POSTGRES_PASSWORD : django_password
34+ POSTGRES_DB : django_db
35+ DB_HOST : 127.0.0.1
36+ DB_PORT : 5432
37+ run : |
38+ python -m flake8 backend/
39+ cd backend/
40+ python manage.py test
4441
4542 build_and_push_to_docker_hub :
4643 name : Push Docker image to DockerHub
4744 runs-on : ubuntu-latest
4845 needs : tests
49- env :
50- DJANGO_SECRET_KEY : ${{ secrets.DJANGO_SECRET_KEY }}
5146 steps :
5247 - name : Check out the repo
5348 uses : actions/checkout@v3
@@ -68,19 +63,19 @@ jobs:
6863 frontend_tests :
6964 runs-on : ubuntu-latest
7065 steps :
71- - uses : actions/checkout@v3
72- - name : Set up nodeJS
73- uses : actions/setup-node@v3
74- with :
75- node-version : 18
76- - name : Install dependencies
77- run : |
78- cd frontend/
79- npm ci
80- - name : Test frontend
81- run : |
82- cd frontend/
83- npm run test
66+ - uses : actions/checkout@v3
67+ - name : Set up nodeJS
68+ uses : actions/setup-node@v3
69+ with :
70+ node-version : 18
71+ - name : Install dependencies
72+ run : |
73+ cd frontend/
74+ npm ci
75+ - name : Test frontend
76+ run : |
77+ cd frontend/
78+ npm run test
8479
8580 build_frontend_and_push_to_docker_hub :
8681 name : Push frontend Docker image to DockerHub
@@ -130,52 +125,42 @@ jobs:
130125 - build_frontend_and_push_to_docker_hub
131126 - build_gateway_and_push_to_docker_hub
132127 if : github.ref == 'refs/heads/main'
133- env :
134- POSTGRES_DB : ${{ secrets.POSTGRES_DB }}
135- POSTGRES_USER : ${{ secrets.POSTGRES_USER }}
136- POSTGRES_PASSWORD : ${{ secrets.POSTGRES_PASSWORD }}
137- DB_HOST : ${{ secrets.DB_HOST }}
138- DB_PORT : ${{ secrets.DB_PORT }}
139- DJANGO_SECRET_KEY : ${{ secrets.DJANGO_SECRET_KEY }}
140- DJANGO_DEBUG : ${{ secrets.DJANGO_DEBUG }}
141- DJANGO_ALLOWED_HOSTS : ${{ secrets.DJANGO_ALLOWED_HOSTS }}
142128 steps :
143- - name : Checkout repo
144- uses : actions/checkout@v3
129+ - name : Checkout repo
130+ uses : actions/checkout@v3
131+ - name : Copy docker-compose.yml via ssh
132+ uses : appleboy/scp-action@master
133+ with :
134+ host : ${{ secrets.HOST }}
135+ username : ${{ secrets.USER }}
136+ key : ${{ secrets.SSH_KEY }}
137+ passphrase : ${{ secrets.SSH_PASSPHRASE }}
138+ source : " docker-compose.production.yml"
139+ target : " kittygram"
145140
146- - name : Copy docker-compose.yml via ssh
147- uses : appleboy/scp-action@master
148- with :
149- host : ${{ secrets.HOST }}
150- username : ${{ secrets.USER }}
151- key : ${{ secrets.SSH_KEY }}
152- passphrase : ${{ secrets.SSH_PASSPHRASE }}
153- source : " docker-compose.production.yml"
154- target : " kittygram"
155-
156- - name : Executing remote ssh commands to deploy
157- uses : appleboy/ssh-action@master
158- with :
159- host : ${{ secrets.HOST }}
160- username : ${{ secrets.USER }}
161- key : ${{ secrets.SSH_KEY }}
162- passphrase : ${{ secrets.SSH_PASSPHRASE }}
163- script : |
164- cd kittygram
165- sudo docker compose -f docker-compose.production.yml pull
166- sudo docker compose -f docker-compose.production.yml down
167- sudo docker compose -f docker-compose.production.yml up -d
168- sudo docker compose -f docker-compose.production.yml exec backend python manage.py migrate
169- sudo docker compose -f docker-compose.production.yml exec backend python manage.py collectstatic --noinput
141+ - name : Executing remote ssh commands to deploy
142+ uses : appleboy/ssh-action@master
143+ with :
144+ host : ${{ secrets.HOST }}
145+ username : ${{ secrets.USER }}
146+ key : ${{ secrets.SSH_KEY }}
147+ passphrase : ${{ secrets.SSH_PASSPHRASE }}
148+ script : |
149+ cd kittygram
150+ sudo docker compose -f docker-compose.production.yml pull
151+ sudo docker compose -f docker-compose.production.yml down
152+ sudo docker compose -f docker-compose.production.yml up -d
153+ sudo docker compose -f docker-compose.production.yml exec backend python manage.py migrate
154+ sudo docker compose -f docker-compose.production.yml exec backend python manage.py collectstatic --noinput
170155
171156 send_message :
172157 runs-on : ubuntu-latest
173158 needs : deploy
174159 if : github.ref == 'refs/heads/main'
175160 steps :
176- - name : Send message
177- uses : appleboy/telegram-action@master
178- with :
179- to : ${{ secrets.TELEGRAM_TO }}
180- token : ${{ secrets.TELEGRAM_TOKEN }}
181- message : Деплой успешно выполнен!
161+ - name : Send message
162+ uses : appleboy/telegram-action@master
163+ with :
164+ to : ${{ secrets.TELEGRAM_TO }}
165+ token : ${{ secrets.TELEGRAM_TOKEN }}
166+ message : Деплой успешно выполнен!
0 commit comments