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

1 #28

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

1 #28

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
441698d
ваш_коммойÑâ€
Alexander28-31 Sep 19, 2022
d0114ef
Create main.yml
Alexander28-31 Sep 20, 2022
e76f7eb
add test with flake8
Alexander28-31 Sep 20, 2022
e236c02
Test
Alexander28-31 Sep 20, 2022
85043a4
Initial commit
Sep 22, 2022
534e0a2
Test
Sep 22, 2022
683273c
Test_1
Sep 22, 2022
1d0e671
Test_1
Sep 22, 2022
b9f5fd1
Merge remote-tracking branch 'origin/main'
Alexander28-31 Sep 22, 2022
ba1945a
Merge remote-tracking branch 'origin/main'
Alexander28-31 Sep 22, 2022
406b8b1
Merge remote-tracking branch 'origin/main'
Alexander28-31 Sep 22, 2022
d94fc78
Merge remote-tracking branch 'origin/main'
Alexander28-31 Sep 22, 2022
566dd73
Merge remote-tracking branch 'origin/main'
Alexander28-31 Sep 23, 2022
3c6b6d6
Sprint16
Alexander28-31 Sep 23, 2022
ea320c9
Merge remote-tracking branch 'origin/main'
Alexander28-31 Sep 23, 2022
dc93546
Merge remote-tracking branch 'origin/main'
Alexander28-31 Sep 23, 2022
b3cb5e5
Merge remote-tracking branch 'origin/main'
Alexander28-31 Sep 23, 2022
7cd78ce
Merge remote-tracking branch 'origin/main'
Alexander28-31 Sep 23, 2022
ed9516a
Merge remote-tracking branch 'origin/main'
Alexander28-31 Sep 23, 2022
43152d6
Merge remote-tracking branch 'origin/main'
Alexander28-31 Sep 23, 2022
6589fc5
Merge remote-tracking branch 'origin/main'
Alexander28-31 Sep 23, 2022
2c455e0
Merge remote-tracking branch 'origin/main'
Alexander28-31 Sep 23, 2022
996ee86
Merge remote-tracking branch 'origin/main'
Alexander28-31 Sep 23, 2022
722b4ba
Merge remote-tracking branch 'origin/main'
Alexander28-31 Sep 23, 2022
2edc318
Merge remote-tracking branch 'origin/main'
Alexander28-31 Sep 23, 2022
5a2391e
Merge remote-tracking branch 'origin/main'
Alexander28-31 Sep 23, 2022
6088059
Merge remote-tracking branch 'origin/main'
Alexander28-31 Sep 23, 2022
46a5f95
Merge remote-tracking branch 'origin/main'
Alexander28-31 Sep 23, 2022
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
82 changes: 82 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# .github/workflows/**main.yml**
name: Django-app workflow

on: [push]

jobs:
tests:
# «Раннер» — создание изолированного окружения с последней версией Ubuntu
runs-on: ubuntu-latest

steps:
# Запуск actions checkout — готового скрипта
# для клонирования репозитория
- uses: actions/checkout@v2
- name: Set up Python
# Запуск actions setup-python — готового скрипта
# для развёртывания окружения Python
uses: actions/setup-python@v2
with:
# Выбор версии Python
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/
# запустить написанные разработчиком тесты

deploy:
runs-on: ubuntu-latest
needs: build_and_push_to_docker_hub
steps:
- name: executing remote ssh commands to deploy
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USER_VM }}
key: ${{ secrets.SSH_KEY }}
passphrase: ${{ secrets.PASSPHRASE }} # Если ваш ssh-ключ защищён фразой-паролем
script: |
# Выполняет pull образа с DockerHub
sudo docker pull bednenko1604/test:v1
#остановка всех контейнеров
sudo docker stop $(sudo docker ps -a -q)
sudo docker run --rm -d -p 5000:5000 bednenko1604/test:v1

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
# Проверка доступности репозитория Docker Hub для workflow
uses: actions/checkout@v2
- name: Set up Docker Buildx
# Вызов сборщика контейнеров docker
uses: docker/setup-buildx-action@v1
- name: Login to Docker
# Запуск скрипта авторизации на Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.USER}}
password: ${{ secrets.PASSPHRASE}}
- name: Push to Docker Hub
# Пуш образа в Docker Hub
uses: docker/build-push-action@v2
with:
push: true
tags: bednenko1604/test:v1

10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,12 @@
# infra_actions
Учебный проект для изучения работы GitHub Actions (Яндекс Практикум)

## Запуск проета
Клонировать репозиторий
```git clone [email protected]:<ваш_username>/infra_actions.git```

Создать и активровать окружение
```python -m venv venv && . venv/bin/activate```

Установить зависимости
```pip install -r requirements.txt ```
3 changes: 2 additions & 1 deletion 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 All @@ -20,4 +21,4 @@ def test_page_shows_correct_content(self):
self.assertContains(response, 'У меня получилось!')

response = self.guest_client.get('/second_page/')
self.assertContains(response, 'А это вторая страница!')
self.assertContains(response, 'А это вторая страница')
2 changes: 1 addition & 1 deletion infra_project/infra_app/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@

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_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
3 changes: 2 additions & 1 deletion infra_project/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@


def main():
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'infra_project.settings')
os.environ.setdefault('DJANGO_SETTINGS_MODULE',
'infra_project.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
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