Merge pull request #16 from Gray-Advantage/dev #44
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: | |
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 | |
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 | |
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 | |
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 all | |
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 all |