MLOps/.gitea/workflows/mlops-pipeline.yml
2025-10-01 17:35:13 +02:00

90 lines
2.2 KiB
YAML

name: MLOps CI/CD Pipeline
on:
push:
branches: [main, dev]
pull_request:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Install dependencies
run: |
pip install poetry
poetry install
- name: Setup DVC
run: |
poetry run dvc remote list
poetry run dvc pull || echo "DVC pull failed, continuing..."
- name: Start API server
run: |
poetry run uvicorn src.api.main:app --host 0.0.0.0 --port 8000 &
sleep 10
- name: Run unit tests
run: poetry run pytest tests/ --cov=src --cov-report=xml
train:
needs: test
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Install dependencies
run: |
pip install poetry
poetry install
- name: Setup DVC
run: |
poetry run dvc remote list
poetry run dvc pull || echo "DVC pull failed, continuing..."
- name: Run DVC pipeline
run: poetry run dvc repro
env:
MLFLOW_TRACKING_URI: ${{ secrets.MLFLOW_TRACKING_URI }}
MLFLOW_TRACKING_USERNAME: ${{ secrets.MLFLOW_TRACKING_USERNAME }}
MLFLOW_TRACKING_PASSWORD: ${{ secrets.MLFLOW_TRACKING_PASSWORD }}
- name: Push DVC changes
run: |
poetry run dvc push || echo "DVC push failed, continuing..."
deploy:
needs: train
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v3
- name: Build Docker image
run: |
docker build -t csgo-mlops:${{ github.sha }} .
docker tag csgo-mlops:${{ github.sha }} csgo-mlops:latest
- name: Push to registry
run: |
docker push csgo-mlops:${{ github.sha }}
docker push csgo-mlops:latest
- name: Deploy to Kubernetes
run: kubectl apply -f kubernetes/deployment.yml