Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

12 #37

Open
wants to merge 28 commits into
base: main
Choose a base branch
from
Open

12 #37

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@

name: Django-app workflow

on: [push]

jobs:
tests:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python

uses: actions/setup-python@v2
with:
python-version: 3.7

- name: Install dependencies
run: |
# обновдение pip
python -m pip install --upgrade pip
# установка flake8 и его плагинов
pip install flake8 pep8-naming flake8-broken-line flake8-return flake8-isort
# установка зависимостей
pip install -r requirements.txt

- name: Test with flake8 and django tests
run: |
# запуск проверки проекта по flake8
python -m flake8
# перейти в папку, содержащую manage.py -
# <корневая папка infra_actions>/<папка проекта>/manage.py
cd infra_project/
# запустить написаные разработчиком тесты
python manage.py test

build_and_push_to_docker_hub:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
needs: tests
steps:
- name: Check out the repo
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to Docker
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Push to Docker Hub
uses: docker/build-push-action@v2
with:
push: true
tags: ruslan2612/wer_v2:latest

deploy:
runs-on: ubuntu-latest
needs: build_and_push_to_docker_hub
steps:
- name: executing remote ssh command to deploy
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USER }}
key: ${{ secrets.SSH_KEY }}
script: |
# Выполняет pull образа с DockerHub
sudo docker pull ruslan2612/wer_v2
# остановка всех контейнеров
sudo docker stop $(sudo docker ps -a -q)
sudo docker run --rm -d -p 5000:5000 ruslan2612/wer_v2
1 change: 1 addition & 0 deletions infra_project/infra_app/tests.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from http import HTTPStatus

from django.test import Client, TestCase


Expand Down
3 changes: 1 addition & 2 deletions infra_project/infra_app/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@

urlpatterns = [
path('', views.index, name='index'),
path('second/', views.second_page, name='second_page'),

path('second_page/', views.second_page, name='second_page'),
]
2 changes: 1 addition & 1 deletion infra_project/infra_app/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ def index(request):


def second_page(request):
return HttpResponse('А это вторая страница')
return HttpResponse('А это вторая страница!')
4 changes: 3 additions & 1 deletion infra_project/infra_project/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []
ALLOWED_HOSTS = [
'178.154.223.155'
]


# Application definition
Expand Down
2 changes: 1 addition & 1 deletion infra_project/infra_project/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, include
from django.urls import include, path

urlpatterns = [
path('', include('infra_app.urls', namespace='infra_app')),
Expand Down
12 changes: 12 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[flake8]
ignore =
W503,
F811
exclude =
tests/,
*/migrations/,
venv/,
env/
per-file-ignores =
*/settings.py:E501
max-complexity = 10