-
Notifications
You must be signed in to change notification settings - Fork 0
101 lines (92 loc) · 2.89 KB
/
python-app.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
97
98
99
100
101
name: Python application
on:
push:
branches: [ "main", "dev", "artem", "sergey", "vladimir", "for_merge"]
pull_request:
branches: [ "main", "dev", "artem", "sergey", "vladimir", "for_merge"]
permissions:
contents: read
jobs:
black-test:
runs-on: ubuntu-latest
container: python:3.10
steps:
- uses: actions/checkout@v3
- name: Install dependencies
run: pip install black
- name: Check code formatting with black
run: black ./datanar/ --check --verbose --diff --line-length 79
flake8-test:
runs-on: ubuntu-latest
container: python:3.10
steps:
- uses: actions/checkout@v3
- name: Install dependencies
run: pip install -r requirements/test.txt
- name: Check code formatting with flake8
run: flake8 ./datanar/ --config=.flake8
django-test:
runs-on: ubuntu-latest
container: python:3.10
steps:
- uses: actions/checkout@v3
- name: Install dependencies
run: pip install -r requirements/dev.txt
- name: Run Django tests
run: |
cd ./datanar
python manage.py test
test-deploy:
if: github.ref == 'refs/heads/dev'
needs: [black-test, flake8-test, django-test]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Deploy to server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
key: ${{ secrets.SERVER_SSH_KEY }}
script: |
sudo supervisorctl stop test_gunicorn test_celery
cd ~/test_datanar
git reset --hard origin/dev
git pull origin dev
source venv/bin/activate
pip install -r requirements/dev.txt
cd ~/test_datanar/datanar
python manage.py migrate
python manage.py compilemessages
python manage.py collectstatic --no-input
deactivate
cd ~
sudo supervisorctl start test_gunicorn test_celery
prod-deploy:
if: github.ref == 'refs/heads/main'
needs: [black-test, flake8-test, django-test]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Deploy to server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
key: ${{ secrets.SERVER_SSH_KEY }}
script: |
sudo supervisorctl stop gunicorn celery
cd ~/datanar
git reset --hard origin/main
git pull origin main
source venv/bin/activate
pip install -r requirements/dev.txt
cd ~/datanar/datanar
python manage.py migrate
python manage.py compilemessages
python manage.py collectstatic --no-input
deactivate
cd ~
sudo supervisorctl start gunicorn celery