Skip to content

Merge pull request #135 from QActf/plans_sorted_courses #488

Merge pull request #135 from QActf/plans_sorted_courses

Merge pull request #135 from QActf/plans_sorted_courses #488

Workflow file for this run

name: fastapi-app workflow
on:
push:
branches: [ "develop" ]
pull_request:
branches: [ "develop" ]
workflow_dispatch:
jobs:
tests_lint:
runs-on: ubuntu-latest
name: Lint
steps:
- name: Check out source repository
uses: actions/checkout@v3
- name: Set up Python environment
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: flake8 Lint
uses: py-actions/flake8@v2
with:
path: "app"
args: "--config setup.cfg"
- uses: isort/isort-action@master
with:
configuration: .setup.cfg
pytest:
runs-on: ubuntu-latest
name: pytest
needs: tests_lint
services:
postgres:
image: postgres:16.2-alpine
ports:
- 5432:5432
env:
POSTGRES_USER: ${{ secrets.POSTGRES_USER }}
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
POSTGRES_DB: ${{ secrets.POSTGRES_DB_TEST }}
POSTGRES_HOST: ${{ secrets.POSTGRES_HOST_TEST }}
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
run: |
pip install --upgrade pip
pip install -r app/requirements.txt
- name: Test with pytest
env:
DATABASE_URL: postgresql+asyncpg://${{ secrets.POSTGRES_USER }}:${{ secrets.POSTGRES_PASSWORD }}@${{ secrets.POSTGRES_HOST_TEST }}:5432/${{ secrets.POSTGRES_DB }}
EMAIL_MOCK_SERVER: ${{ secrets.EMAIL_MOCK_SERVER }}
EMAIL_FROM: ${{ secrets.EMAIL_FROM }}
EMAIL_HOST: ${{ secrets.EMAIL_HOST }}
EMAIL_PORT: ${{ secrets.EMAIL_PORT }}
EMAIL_HOST_USER: ${{ secrets.EMAIL_HOST_USER }}
EMAIL_HOST_PASSWORD: ${{ secrets.EMAIL_HOST_PASSWORD }}
run: |
pytest
deploy:
if: ${{ github.event_name == 'push' }}
runs-on: ubuntu-latest
needs: pytest
steps:
- uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USER }}
key: ${{ secrets.SSH_KEY }}
script: |
cd backend/
git pull
cd infra/
touch .env
echo DATABASE_URL=${{ secrets.DATABASE_URL }} >> .env
echo EMAIL_MOCK_SERVER =${{ secrets.EMAIL_MOCK_SERVER }} >> .env
echo EMAIL_FROM=${{ secrets.EMAIL_FROM }} >> .env
echo EMAIL_HOST=${{ secrets.EMAIL_HOST }} >> .env
echo EMAIL_PORT=${{ secrets.EMAIL_PORT }} >> .env
echo EMAIL_HOST_USER=${{ secrets.EMAIL_HOST_USER }} >> .env
echo EMAIL_HOST_PASSWORD=${{ secrets.EMAIL_HOST_PASSWORD }} >> .env
echo HOST=${{ secrets.HOST }} >> .env
echo ${{ secrets.SUDO_PASSWORD }} | sudo -S docker compose down
echo ${{ secrets.SUDO_PASSWORD }} | sudo -S docker rmi infra-backend:latest
echo ${{ secrets.SUDO_PASSWORD }} | sudo -S docker compose up -d --build