Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Deploy

on:
push:
branches: [main]

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install Clever Tools
run: npm install -g clever-tools

- name: Deploy to Clever Cloud
env:
CLEVER_TOKEN: ${{ secrets.CLEVER_TOKEN }}
CLEVER_SECRET: ${{ secrets.CLEVER_SECRET }}
run: clever deploy --same-commit-policy rebuild
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ uv run pipelines/run.py run build_database
uv run python manage.py migrate
uv run python manage.py runserver

# Frontend (autre terminal)
cd frontend && npm install && npm run dev
# Frontend (dev, autre terminal)
cd frontend && npm ci && npm run dev

# Frontend (prod build, servi par Django/WhiteNoise)
cd frontend && npm ci && npm run build
uv run python manage.py runserver
```

Push sur `main` → GitHub Action lance `clever deploy`. Clever exécute
`scripts/clever-post-build.sh` (build React + migrate + collectstatic).
Secrets dépôt : `CLEVER_TOKEN`, `CLEVER_SECRET`.
6 changes: 6 additions & 0 deletions config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,10 @@
STATIC_URL = "/static/"
STATIC_ROOT = BASE_DIR / "staticfiles"

# Vite production build (npm run build → frontend/dist/).
FRONTEND_DIR = BASE_DIR / "frontend" / "dist"
if FRONTEND_DIR.is_dir():
# Serve /assets/* (and other built files) at site root via WhiteNoise.
WHITENOISE_ROOT = FRONTEND_DIR

DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
14 changes: 10 additions & 4 deletions config/urls.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
"""URL configuration."""

from pathlib import Path

from django.conf import settings
from django.contrib import admin
from django.http import HttpResponse
from django.urls import path
from django.urls import path, re_path


def home(_request):
return HttpResponse("Le Dessous des Algorithmes")
def spa(_request):
index = Path(settings.FRONTEND_DIR) / "index.html"
if not index.is_file():
return HttpResponse("Frontend not built.", status=503)
return HttpResponse(index.read_text(encoding="utf-8"), content_type="text/html")


urlpatterns = [
path("", home, name="home"),
path("admin/", admin.site.urls),
re_path(r"^.*$", spa, name="spa"),
]
Loading
Loading