Skip to content

Commit

Permalink
messages telegram_bot
Browse files Browse the repository at this point in the history
  • Loading branch information
georgii265 committed Jun 19, 2023
1 parent 9f6fd2e commit 8fa96bd
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ jobs:

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade pip
pip install flake8==6.0.0 flake8-isort==6.0.0
pip install -r ./backend/requirements.txt
pip install -r ./backend/requirements.txt
# Этот шаг дополним переменными для доступа к БД
- name: Test with flake8 and django tests
# Добавляем env-переменные для доступа к БД
Expand All @@ -52,7 +52,7 @@ jobs:
python -m flake8 backend/
cd backend/
python manage.py test
# Добавляем новую задачу: деплой приложения
build_and_push_to_docker_hub:
name: Push Docker image to DockerHub
Expand All @@ -65,12 +65,12 @@ jobs:
- name: Set up Docker Buildx
# Установка сборщика контейнеров Docker
uses: docker/setup-buildx-action@v2
- name: Login to Docker
- name: Login to Docker
# Авторизация на Docker Hub
uses: docker/login-action@v2
# При помощи with передаём в action параметры username и password
with:
username: ${{ secrets.DOCKER_USERNAME }}
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# Хорошо ли держать логин и пароль прямо в коде workflow?
# Нет, это нехорошо
Expand All @@ -89,7 +89,7 @@ jobs:
# устанавливаем тег latest, чтобы потом
# на сервере и в docker-compose.yml не указывать версию
tags: georgii265/taski_backend:latest

frontend_tests:
runs-on: ubuntu-latest

Expand Down Expand Up @@ -123,7 +123,7 @@ jobs:
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker
- name: Login to Docker
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
Expand All @@ -134,7 +134,7 @@ jobs:
context: ./frontend/
push: true
tags: georgii265/taski_frontend:latest

build_gateway_and_push_to_docker_hub:
name: Push gateway Docker image to DockerHub
runs-on: ubuntu-latest
Expand All @@ -143,7 +143,7 @@ jobs:
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker
- name: Login to Docker
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
Expand All @@ -158,7 +158,7 @@ jobs:

deploy:
runs-on: ubuntu-latest
needs:
needs:
# Дождёмся билда всех образов Taski
- build_and_push_to_docker_hub
- build_frontend_and_push_to_docker_hub
Expand Down Expand Up @@ -197,4 +197,15 @@ jobs:
# Выполняет миграции и сбор статики
sudo docker compose -f docker-compose.production.yml exec backend python manage.py migrate
sudo docker compose -f docker-compose.production.yml exec backend python manage.py collectstatic
sudo docker compose -f docker-compose.production.yml exec backend cp -r collected_static/. ../backend_static/static/
sudo docker compose -f docker-compose.production.yml exec backend cp -r collected_static/. ../backend_static/static/
send_message:
runs-on: ubuntu-latest
needs: deploy
steps:
- name: Send message
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_TO }}
token: ${{ secrets.TELEGRAM_TOKEN }}
message: Деплой успешно выполнен!

0 comments on commit 8fa96bd

Please sign in to comment.