diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..6941a56 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,78 @@ +name: Main Workflow + +on: + push: + branches: + - dev + +jobs: +# test: +# runs-on: ubuntu-24.04 + +# services: +# postgres: +# image: postgres:16 +# env: +# POSTGRES_USER: ${{ secrets.POSTGRES_USER }} +# POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }} +# POSTGRES_DB: ${{ secrets.POSTGRES_DB }} +# ports: +# - 5432:5432 +# options: >- +# --health-cmd "pg_isready -U ${{ secrets.POSTGRES_USER }}" +# --health-interval 10s +# --health-timeout 5s +# --health-retries 5 + +# adminer: +# image: adminer:4.8.1 +# ports: +# - 8080:8080 + +# steps: +# - name: Checkout 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 -r requirements.txt + +# - name: Run tests +# env: +# DATABASE_URL: postgres://postgres:${{ secrets.POSTGRES_PASSWORD }}@localhost:5432/${{ secrets.POSTGRES_DB }} +# run: | +# pytest + + deploy: + runs-on: ubuntu-24.04 + # needs: test + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Deploy to server + uses: appleboy/ssh-action@v0.1.5 + with: + host: ${{ secrets.HOST }} + username: ${{ secrets.USER }} + key: ${{ secrets.SSH_KEY }} + passphrase: ${{ secrets.SSH_PASSPHRASE }} + script: | + cd /Privet_Logoped_team_4/ + git pull origin dev + source /Privet_Logoped_team_4/src/telegram_bot/venv/bin/activate + pip install -r src/telegram_bot/requirements.txt + alembic upgrade head + deactivate + source /Privet_Logoped_team_4/src/vk_bot/venv/bin/activate + pip install -r src/vk_bot/requirements.txt + deactivate + sudo systemctl restart docker-compose-db.service + sudo systemctl restart telegram-bot.service + sudo systemctl restart vk-bot.service diff --git a/docker-compose.yaml b/docker-compose.yaml index 6b43e6f..d4250ef 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,22 +1,33 @@ version: '3' services: - - db: - image: postgres - restart: always - shm_size: 128mb - volumes: - - db-data:/var/lib/postgresql/data - env_file: .env + postgres: + image: postgres:16 + container_name: postgres_db + environment: + POSTGRES_USER: ${POSTGRES_USER} + POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} + POSTGRES_DB: ${POSTGRES_DB} ports: - - "5433:5432" + - "5432:5432" + volumes: + - postgres_data:/var/lib/postgresql/data + networks: + - db_network adminer: - image: adminer - restart: always + image: adminer:4.8.1 + container_name: adminer ports: - "8080:8080" + networks: + - db_network + depends_on: + - postgres volumes: - db-data: + postgres_data: + +networks: + db_network: + driver: bridge