2026-09-19 12:31:30 +02:00
|
|
|
name: CI/CD
|
2026-09-19 12:11:06 +02:00
|
|
|
|
|
|
|
|
on:
|
|
|
|
|
push:
|
|
|
|
|
branches: [main, dev]
|
|
|
|
|
pull_request:
|
|
|
|
|
branches: [main]
|
|
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
|
lint:
|
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
steps:
|
|
|
|
|
- uses: actions/checkout@v4
|
|
|
|
|
|
|
|
|
|
- uses: actions/setup-python@v5
|
|
|
|
|
with:
|
|
|
|
|
python-version: "3.12"
|
|
|
|
|
|
|
|
|
|
- name: Install dependencies
|
2026-09-19 12:31:30 +02:00
|
|
|
run: pip install -r requirements.txt -r requirements-dev.txt
|
2026-09-19 12:11:06 +02:00
|
|
|
|
|
|
|
|
- name: Ruff lint
|
|
|
|
|
run: ruff check .
|
|
|
|
|
|
|
|
|
|
- name: Ruff format check
|
|
|
|
|
run: ruff format --check .
|
|
|
|
|
|
|
|
|
|
test:
|
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
steps:
|
|
|
|
|
- uses: actions/checkout@v4
|
|
|
|
|
|
|
|
|
|
- uses: actions/setup-python@v5
|
|
|
|
|
with:
|
|
|
|
|
python-version: "3.12"
|
|
|
|
|
|
|
|
|
|
- name: Install dependencies
|
2026-09-19 12:31:30 +02:00
|
|
|
run: pip install -r requirements.txt -r requirements-dev.txt
|
2026-09-19 12:11:06 +02:00
|
|
|
|
|
|
|
|
- name: Syntax check
|
2026-09-19 12:31:30 +02:00
|
|
|
run: |
|
|
|
|
|
python -m py_compile bot.py
|
|
|
|
|
python -m py_compile vision.py
|
|
|
|
|
python -m py_compile config.py
|
2026-09-19 12:11:06 +02:00
|
|
|
|
|
|
|
|
- name: Run tests
|
|
|
|
|
run: pytest tests/ -v || true
|
2026-09-19 12:31:30 +02:00
|
|
|
|
|
|
|
|
deploy:
|
|
|
|
|
needs: [lint, test]
|
|
|
|
|
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
|
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
steps:
|
|
|
|
|
- uses: actions/checkout@v4
|
|
|
|
|
|
|
|
|
|
- name: Deploy to production server
|
|
|
|
|
uses: appleboy/ssh-action@v1
|
|
|
|
|
with:
|
|
|
|
|
host: ${{ secrets.PROD_HOST }}
|
|
|
|
|
username: ${{ secrets.PROD_USER }}
|
|
|
|
|
password: ${{ secrets.PROD_PASSWORD }}
|
|
|
|
|
script: |
|
|
|
|
|
cd /home/discord/Bots/VisionApp
|
|
|
|
|
git pull origin main --rebase
|
|
|
|
|
if command -v docker &>/dev/null; then
|
|
|
|
|
docker compose build --no-cache vision
|
|
|
|
|
docker compose up -d vision
|
|
|
|
|
else
|
|
|
|
|
pkill -f "python.*vision\.py" 2>/dev/null || true
|
|
|
|
|
source venv/bin/activate
|
|
|
|
|
pip install -r requirements.txt
|
|
|
|
|
nohup python vision.py > /dev/null 2>&1 &
|
|
|
|
|
fi
|