Skip to content

исправляем DisallowedHost at / #60

исправляем DisallowedHost at /

исправляем DisallowedHost at / #60

Workflow file for this run

name: DRF CI/CD Pipeline
#on: [push, pull_request]
on: [ push ]
jobs:
# lint:
# runs-on: ubuntu-latest
#
# steps:
# - name: Check out code
# uses: actions/checkout@v3
#
# - name: Set up Python
# uses: actions/setup-python@v4
# with:
# python-version: '3.12'
#
# - name: Install dependencies
# run: |
# python -m pip install --upgrade pip
# pip install flake8
#
# - name: Run Flake8
# run: flake8 .
# test:
# runs-on: ubuntu-latest
#
# services:
# # needs: lint
# db:
# image: postgres:16-alpine
# env:
# POSTGRES_HOST: 'localhost'
# POSTGRES_DB: 'test_db'
# POSTGRES_USER: 'postgres'
# POSTGRES_PASSWORD: 'some_password'
# ports:
# - 5432:5432
# # Если требуется, вы можете настроить ожидание
# # чтобы PostgreSQL был доступен перед запуском миграций
# options: >-
# --health-cmd pg_isready
# --health-interval 10s
# --health-timeout 5s
# --health-retries 5
#
# steps:
# - name: Checkout repository
# uses: actions/checkout@v2
#
# - name: Set up Python
# uses: actions/setup-python@v2
# with:
# python-version: '3.12' # Замените на вашу версию Python
# cache: 'pip'
#
# - name: Install dependencies
# run: |
#
# python -m pip install --upgrade pip
# pip install -r requirements.txt
# echo "$POSTGRES_USER"
#
# - name: Run migrations
# env:
# SECRET_KEY: 'gxt&zs7&=dm(5umk20(t93a9=##j_*$vi47q!1abrmfr+iu)*$'
# POSTGRES_HOST: 'localhost'
# POSTGRES_DB: 'test_db'
# POSTGRES_USER: 'postgres'
# POSTGRES_PASSWORD: 'some_password'
# run:
#
# python manage.py migrate
#
#
# - name: Run test
## env:
## SECRET_KEY: 'gxt&zs7&=dm(5umk20(t93a9=##j_*$vi47q!1abrmfr+iu)*$'
## POSTGRES_HOST: 'localhost'
## POSTGRES_DB: 'test_db'
## POSTGRES_USER: 'postgres'
## POSTGRES_PASSWORD: 'some_password'
# run:
# echo "$SECRET_KEY"
# python manage.py test
#
deploy:
runs-on: ubuntu-latest
# needs: test
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up SSH
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_KEY }}
- name: Run bash script via ssh
env:
SOME_DIR: ${{ secrets.SOME_DIR }}
run: |
ssh -o StrictHostKeyChecking=no ${{ secrets.SSH_USER }}@${{ secrets.SERVER_IP }} "ls $SOME_DIR"
- name: Copy project files to server
run: |
rsync -avz --exclude '__pycache__' --exclude '.git' . ${{ secrets.SSH_USER }}@${{ secrets.SERVER_IP }}:${{ secrets.DEPLOY_DIR }}
- name: Build image ,pull,push ,up
run: |
ssh -o StrictHostKeyChecking=no ${{ secrets.SSH_USER }}@${{ secrets.SERVER_IP }} << 'EOF'
cd ${{ secrets.DEPLOY_DIR }}
docker compose down --rmi local || true
docker compose build
docker compose up -d
EOF
# cd ${{ secrets.DEPLOY_DIR }}
# pwd docker compose down
#
# docker compose build
# docker compose up -d
# build:
## needs: test
# runs-on: ubuntu-latest
#
# steps:
# - name: Check out code
# uses: actions/checkout@v3
#
# - name: Log in to Docker Hub
# run: echo ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin
#
# - name: Build Docker image
# run: docker compose -f docker-compose.github.yml build
#
# - name: Push Docker image to Docker Hub
# run: docker compose -f docker-compose.github.yml push
#
# deploy:
# needs: build
# runs-on: ubuntu-latest
#
# steps:
# - name: Set up SSH
# uses: webfactory/[email protected]
# with:
# ssh-private-key: ${{ secrets.SSH_KEY }}
#
# - name: Deploy to server
# run: |
# ssh -o StrictHostKeyChecking=no ${{ secrets.SSH_USER }}@${{ secrets.SERVER_IP }} << 'EOF'
# docker pull ${{ secrets.DOCKER_HUB_USER }}/habits:latest
# docker stop habits || true
# docker rm habits || true
# docker run -d --name habits -p 80:8000 ${{ secrets.DOCKER_HUB_USER }}/habits:latest
# EOF