Skip to content

fix: settings.py

fix: settings.py #138

name: API YaMDb Project CI/CD
on: [ push ]
jobs:
tests:
name: Test project
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ "3.10", "3.11", "3.12" ]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
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: |
python -m flake8
pytest
build_and_push_to_docker_hub:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
needs: tests
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main'
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Push to Docker Hub
uses: docker/build-push-action@v5
with:
file: Dockerfile
push: true
tags: chemisto/yamdb_final:latest
deploy:
name: Deploy on Server
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_PRIVATE_KEY }}
passphrase: ${{ secrets.PASSPHRASE }}
script: |
cd ${{ secrets.PROJECT_FOLDER }}
docker compose down
docker compose pull
touch .env
echo "DB_ENGINE=${{ secrets.DB_ENGINE }}
DB_NAME=${{ secrets.DB_NAME }}
POSTGRES_USER=${{ secrets.POSTGRES_USER }}
POSTGRES_PASSWORD=${{ secrets.POSTGRES_PASSWORD }}
DB_HOST=${{ secrets.DB_HOST }}
DB_PORT=${{ secrets.DB_PORT }}" > .env.db
docker compose up -d
send_message:
name: Send message to Telegram
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 }} успешно выполнен!