- .env.dev / .env.prod with separate tokens and APPLICATION_ID - Bot syncs commands to specific guild in dev mode - Global sync for production - Updated .forgejo/workflows/ci.yml with SSH deploy to prod server - Updated .gitignore for .env.dev / .env.prod
73 lines
1.8 KiB
YAML
73 lines
1.8 KiB
YAML
name: CI/CD
|
|
|
|
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
|
|
run: pip install -r requirements.txt -r requirements-dev.txt
|
|
|
|
- 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
|
|
run: pip install -r requirements.txt -r requirements-dev.txt
|
|
|
|
- name: Syntax check
|
|
run: |
|
|
python -m py_compile bot.py
|
|
python -m py_compile vision.py
|
|
python -m py_compile config.py
|
|
|
|
- name: Run tests
|
|
run: pytest tests/ -v || true
|
|
|
|
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
|