68 lines
1.7 KiB
YAML
68 lines
1.7 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: 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 DVC
|
|
run: |
|
|
pip install dvc[s3]
|
|
dvc pull
|
|
|
|
- name: Train model
|
|
run: poetry run python src/models/train.py
|
|
env:
|
|
MLFLOW_TRACKING_URI: ${{ secrets.MLFLOW_URI }}
|
|
MLFLOW_TRACKING_USERNAME: ${{ secrets.CSGO }}
|
|
MLFLOW_TRACKING_PASSWORD: ${{ secrets.MLOPSEPITALYON }}
|
|
|
|
deploy:
|
|
needs: train
|
|
runs-on: ubuntu-latest
|
|
if: github.ref == 'refs/heads/main'
|
|
steps:
|
|
- 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 |