Create parser, update admin panel and fix bugs (#22) #1
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: Deploy | |
on: | |
push: | |
branches: | |
- main | |
- master | |
jobs: | |
tests: | |
runs-on: ubuntu-latest | |
services: | |
postgres: | |
image: postgres:16 | |
env: | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: password | |
POSTGRES_DB: users | |
ports: | |
- 5432:5432 | |
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.11 | |
- name: Install Dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r ./backend/requirements.txt | |
- name: Run tests | |
env: | |
DB_URL: postgresql+asyncpg://postgres:password@postgresql:5432/users | |
run: | | |
cd backend/ | |
python -m pytest | |
build_and_push_backend: | |
name: Push Docker image to Dockerhub | |
runs-on: ubuntu-latest | |
needs: tests | |
if: ${{ github.event_name == 'push' }} | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to Docker | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Push to DockerHub | |
uses: docker/build-push-action@v4 | |
with: | |
context: ./backend/ | |
push: true | |
tags: wolfmtk/sozidateli_backend | |
build_and_push_bot: | |
name: Push Docker image to Dockerhub | |
runs-on: ubuntu-latest | |
needs: tests | |
if: ${{ github.event_name == 'push' }} | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to Docker | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Push to DockerHub | |
uses: docker/build-push-action@v4 | |
with: | |
context: ./bot/ | |
push: true | |
tags: wolfmtk/sozidateli_bot | |
build_and_push_gateway: | |
name: Push Docker image to Dockerhub | |
runs-on: ubuntu-latest | |
needs: tests | |
if: ${{ github.event_name == 'push' }} | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to Docker | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Push to DockerHub | |
uses: docker/build-push-action@v4 | |
with: | |
context: ./nginx/ | |
push: true | |
tags: wolfmtk/sozidateli_gateway | |
deploy: | |
runs-on: ubuntu-latest | |
needs: | |
- build_and_push_backend | |
- build_and_push_bot | |
- build_and_push_gateway | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v3 | |
- name: Copy docker-compose.yml via ssh | |
uses: appleboy/scp-action@master | |
with: | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.USER }} | |
key: ${{ secrets.SSH_KEY }} | |
password: ${{ secrets.SSH_PASSWORD }} | |
source: "docker-compose.production.yml" | |
target: "sozidateli" | |
- name: Executing remote ssh commands to deploy | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.USER }} | |
key: ${{ secrets.SSH_KEY }} | |
password: ${{ secrets.SSH_PASSWORD }} | |
script: | | |
cd sozidateli | |
sudo docker compose -f docker-compose.production.yml pull | |
sudo docker compose -f docker-compose.production.yml down | |
sudo docker compose -f docker-compose.production.yml up -d | |
sudo docker image prune -fa | |
send_message_deploy: | |
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: Деплой успешно выполнен! |