Skip to content

Update main.yml

Update main.yml #82

Workflow file for this run

name: mlflow application
on:
push:
branches: [ "experimental" ]
pull_request:
branches: [ "experimental" ]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:13
env:
POSTGRES_USER: testuser
POSTGRES_PASSWORD: testpassword
POSTGRES_DB: testdb
ports:
- 5432:5432
options: >
--health-cmd="pg_isready -U testuser"
--health-interval=10s
--health-timeout=5s
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.9'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Wait for PostgreSQL to be ready
run: |
echo "Waiting for PostgreSQL to start..."
for i in {1..10}; do
if pg_isready -h localhost -p 5432 -U testuser; then
echo "PostgreSQL is ready!"
break
else
echo "Waiting for PostgreSQL..."
sleep 3
fi
done
- name: Run tests
env:
DB_HOST: localhost
DB_PORT: 5432
DB_USER: testuser
DB_PASSWORD: testpassword
DB_NAME: testdb
run: |
pytest --disable-warnings -v tests/test_def_user.py
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Deploy to server
uses: appleboy/[email protected]
with:
host: ${{ secrets.VPS_HOST }}
username: ${{ secrets.VPS_USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
if [ ! -d "app_api" ]; then
mkdir app_api
cd app_api
git clone https://github.com/redhox/labeling_api.git .
else
cd app_api
docker stop app_api
git pull origin main
fi
docker build -t app_api -f ./Dockerfile .
docker run --rm -d \
-p 8002:8002 \
-e ENDPOINT_URL=${{ secrets.ENDPOINT_URL }} \
-e AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }} \
-e AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }} \
-e REGION_NAME="us-east-1" \
-e SIGNATURE_VERSION="s3v4" \
-e BUCKET_NAME=${{ secrets.BUCKET_NAME }} \
-e MLFLOW_URL=${{ secrets.MLFLOW_URL }} \
-e MLFLOW_USER=${{ secrets.MLFLOW_USER }} \
-e MLFLOW_PASSWORD=${{ secrets.MLFLOW_PASSWORD }} \
-e MLFLOW_BUCKET_NAME=${{ secrets.MLFLOW_BUCKET_NAME }} \
-e POSTGRES_USER=${{ secrets.POSTGRES_USER }} \
-e POSTGRES_PASSWORD=${{ secrets.POSTGRES_PASSWORD }} \
-e POSTGRES_HOST=${{ secrets.POSTGRES_HOST }} \
-e POSTGRES_DB=${{ secrets.POSTGRES_DB }} \
-e MONGO_INITDB_ROOT_USERNAME=${{ secrets.MONGO_INITDB_ROOT_USERNAME }} \
-e MONGO_INITDB_ROOT_PASSWORD=${{ secrets.MONGO_INITDB_ROOT_PASSWORD }} \
-e MONGO_DB=${{ secrets.MONGO_DB }} \
-e MONGO_HOST=${{ secrets.MONGO_HOST }} \
-e MONGO_PORT=27017 \
-e ALGORITHM=HS256 \
-e ACCESS_TOKEN_EXPIRE_MINUTES=300 \
--name app_api \
app_api uvicorn app.main:app --host 0.0.0.0 --port 8002 --reload