redoc fixes #25
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: Django-app workflow | |
on: [push] | |
jobs: | |
tests: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.7 | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install flake8 pep8-naming flake8-broken-line flake8-return flake8-isort | |
cd api_yamdb | |
pip install -r requirements.txt | |
- name: Test with flake8 and pytests | |
run: | | |
# запуск проверки проекта по flake8 | |
python -m flake8 | |
python -m pytest | |
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@v3 | |
- name: Login to Docker | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Push to Docker Hub | |
uses: docker/build-push-action@v2 | |
with: | |
context: api_yamdb/ | |
push: true | |
tags: ${{ secrets.DOCKERHUB_USERNAME }}/yamdb_final:latest | |
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 }} | |
key: ${{ secrets.SSH_KEY }} | |
script: | | |
sudo docker-compose stop | |
sudo docker-compose rm web | |
touch .env | |
echo DB_ENGINE=${{ secrets.DB_ENGINE }} >> .env | |
echo DB_NAME=${{ secrets.DB_NAME }} >> .env | |
echo POSTGRES_USER=${{ secrets.POSTGRES_USER }} >> .env | |
echo POSTGRES_PASSWORD=${{ secrets.POSTGRES_PASSWORD }} >> .env | |
echo DB_HOST=${{ secrets.DB_HOST }} >> .env | |
echo DB_PORT=${{ secrets.DB_PORT }} >> .env | |
sudo docker pull ${{ secrets.DOCKERHUB_USERNAME }}/yamdb_final:latest | |
sudo docker-compose up -d | |
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: ${{ github.workflow }} успешно выполнен! |