VisionApp/.forgejo/workflows/ci.yml

77 lines
2.1 KiB
YAML
Raw Normal View History

name: CI/CD
on:
push:
branches: [main, dev]
pull_request:
branches: [main]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
run: |
git clone --depth 1 https://omegakubeserv.tail951d2f.ts.net/Omega_Kube/VisionApp.git .
git fetch --all
- name: Setup Python
run: |
apt-get update && apt-get install -y python3 python3-pip python3-venv
python3 -m venv .venv
. .venv/bin/activate
pip install -r requirements.txt -r requirements-dev.txt
- name: Ruff lint
run: |
. .venv/bin/activate
ruff check .
- name: Ruff format check
run: |
. .venv/bin/activate
ruff format --check .
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
run: |
git clone --depth 1 https://omegakubeserv.tail951d2f.ts.net/Omega_Kube/VisionApp.git .
- name: Setup Python
run: |
apt-get update && apt-get install -y python3 python3-pip python3-venv
python3 -m venv .venv
. .venv/bin/activate
pip install -r requirements.txt -r requirements-dev.txt
- name: Syntax check
run: |
. .venv/bin/activate
python3 -m py_compile bot.py
python3 -m py_compile vision.py
python3 -m py_compile config.py
- name: Run tests
run: |
. .venv/bin/activate
pytest tests/ -v || true
deploy:
needs: [lint, test]
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- name: Deploy to production
run: |
apt-get update && apt-get install -y sshpass openssh-client
sshpass -p "${{ secrets.PROD_PASSWORD }}" ssh -o StrictHostKeyChecking=no ${{ secrets.PROD_USER }}@${{ secrets.PROD_HOST }} << 'DEPLOY'
cd /home/discord/Bots/VisionApp
git pull origin main --rebase
source venv/bin/activate
pip install -r requirements.txt
sudo systemctl restart vision-studio
echo "Deploy OK"
DEPLOY