Skip to content
Closed
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
75 changes: 37 additions & 38 deletions .github/workflows/audit.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: 'Audit des dépendances npm Backend et Frontend'
name: 'Audit des dépendances npm'

on:
pull_request:
Expand All @@ -9,47 +9,46 @@ on:
- dev

jobs:
npm-audit:
audit-backend:
name: 'Audit Backend'
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18]
steps:
- name: 'Checkout code'
uses: actions/checkout@v4

- name: 'Setup Node.js'
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: saintBarthVolleyApp/backend/package-lock.json

- name: 'Installer les dépendances'
run: npm ci
working-directory: saintBarthVolleyApp/backend

- name: 'Audit npm backend'
run: npm audit --audit-level=critical --omit=dev
working-directory: saintBarthVolleyApp/backend

audit-frontend:
name: 'Audit Frontend'
runs-on: ubuntu-latest
steps:
- name: 'Checkout code'
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: 'Setup Node.js'
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

# ----------------------
# Backend audit
# ----------------------
- name: 'Installation des dépendances backend'
run: |
echo "Installation des dépendances backend"
cd saintBarthVolleyApp/backend
npm install

- name: "Lancement de l'audit npm backend"
run: |
echo "Audit des dépendances backend"
cd saintBarthVolleyApp/backend
npm audit --audit-level=high

# ----------------------
# Frontend audit
# ----------------------
- name: 'Installation des dépendances frontend'
run: |
echo "Installation des dépendances frontend"
cd saintBarthVolleyApp/frontend
npm install

- name: "Lancement de l'audit npm frontend"
run: |
echo "Audit des dépendances frontend"
cd saintBarthVolleyApp/frontend
npm audit --audit-level=high
node-version: '20'
cache: 'npm'
cache-dependency-path: saintBarthVolleyApp/frontend/package-lock.json

- name: 'Installer les dépendances'
run: npm ci
working-directory: saintBarthVolleyApp/frontend

- name: 'Audit npm frontend'
run: npm audit --audit-level=critical --omit=dev
working-directory: saintBarthVolleyApp/frontend
69 changes: 69 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: 'Deploy to VPS'

on:
push:
branches:
- main

jobs:
deploy:
name: 'Déploiement SaintBarth Volley'
runs-on: ubuntu-latest

steps:
- name: 'Checkout code'
uses: actions/checkout@v4

- name: 'Deploy via SSH'
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.VPS_HOST }}
username: ${{ secrets.VPS_USER }}
key: ${{ secrets.VPS_SSH_KEY }}
port: 22
script: |
set -e
echo "🚀 Déploiement SaintBarth Volley"

REPO_DIR="/var/www/SaintBarthVolley"
COMPOSE_FILE="/var/www/docker-compose.yml"

# ── Cloner ou mettre à jour le repo ──────────────────────────
if [ ! -d "$REPO_DIR/.git" ]; then
echo "📥 Premier déploiement — clonage du repo..."
git clone https://github.com/${{ github.repository }}.git "$REPO_DIR"
else
echo "🔄 Mise à jour du code..."
git -C "$REPO_DIR" fetch origin main
git -C "$REPO_DIR" reset --hard origin/main
fi
echo "✅ Code à jour"

# ── Vérifier que le .env backend existe ───────────────────────
ENV_FILE="$REPO_DIR/saintBarthVolleyApp/backend/.env"
if [ ! -f "$ENV_FILE" ]; then
echo "❌ Fichier .env manquant : $ENV_FILE"
echo " Créez-le depuis .env.example avant de déployer."
exit 1
fi
echo "✅ Fichier .env backend trouvé"

# ── Rebuild et restart uniquement les services SaintBarth ─────
echo "🔨 Build des images..."
docker compose -f "$COMPOSE_FILE" build --no-cache sbv-api sbv-front

echo "🔄 Redémarrage des containers..."
docker compose -f "$COMPOSE_FILE" up -d --remove-orphans sbv-api sbv-front

echo "✅ Containers démarrés"

# ── Nettoyage des images obsolètes ────────────────────────────
docker image prune -f

# ── Vérification finale ───────────────────────────────────────
echo ""
echo "📊 État des containers SaintBarth :"
docker ps --filter "name=sbv-" --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"

echo ""
echo "🎉 Déploiement terminé !"
5 changes: 2 additions & 3 deletions .github/workflows/hotfix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:

steps:
- name: 'Checkout code'
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down Expand Up @@ -81,7 +81,6 @@ jobs:
fi

CONTENT=$(echo "$SECTION" | grep -Ev '^(## |\s*$|### )')

if [[ -z "$CONTENT" ]]; then
echo "❌ Le changelog pour la version $VERSION est vide"
exit 1
Expand All @@ -107,4 +106,4 @@ jobs:

- name: 'PR mergée sur dev'
if: github.event.pull_request.base.ref == 'dev'
run: echo "PR mergée sur dev, aucune release ni tag créé."
run: echo "PR mergée sur devaucune release créée."
43 changes: 20 additions & 23 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,38 +11,35 @@ on:
jobs:
lint:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18]

steps:
- name: 'Checkout code'
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: 'Setup Node.js'
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
node-version: '20'
cache: 'npm'
cache-dependency-path: |
saintBarthVolleyApp/backend/package-lock.json
saintBarthVolleyApp/frontend/package-lock.json

- name: 'Installation ESLint & Prettier'
run: |
cd saintBarthVolleyApp/backend
npm init -y
npm install eslint prettier --save-dev
cd ../frontend
npm init -y
npm install eslint prettier --save-dev
- name: 'Installer les dépendances backend'
run: npm ci
working-directory: saintBarthVolleyApp/backend

- name: 'Lancer ESLint backend'
run: |
cd saintBarthVolleyApp/backend
npx eslint . --ext .js,.ts || echo "✅ Pas de fichiers backend JS/TS à lint"
run: npx eslint . --ext .js,.ts
working-directory: saintBarthVolleyApp/backend

- name: 'Installer les dépendances frontend'
run: npm ci
working-directory: saintBarthVolleyApp/frontend

- name: 'Lancer ESLint frontend'
run: |
cd saintBarthVolleyApp/frontend
npx eslint . --ext .js,.jsx || echo "✅ Pas de fichiers frontend JS/JSX à lint"
run: npx eslint . --ext .js,.jsx,.ts,.tsx
working-directory: saintBarthVolleyApp/frontend

- name: 'Lancer Prettier check'
run: |
npx prettier --check . || echo "✅ Pas de fichiers à formater"
- name: 'Prettier check (global)'
run: npx prettier --check "saintBarthVolleyApp/**/*.{js,ts,tsx,jsx,json}" --ignore-path .gitignore
7 changes: 1 addition & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:

steps:
- name: 'Checkout code'
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down Expand Up @@ -69,7 +69,6 @@ jobs:
exit 1
fi

# Extraire uniquement la section de la version
SECTION=$(awk "
BEGIN {found=0}
/^## \\[$VERSION\\]/ {found=1}
Expand All @@ -82,21 +81,17 @@ jobs:
exit 1
fi

# Vérifier que la section contient du contenu réel
CONTENT=$(echo "$SECTION" | grep -Ev '^(## |\s*$|### )')

if [[ -z "$CONTENT" ]]; then
echo "❌ Le changelog pour la version $VERSION est vide"
exit 1
fi

echo "✅ Changelog valide pour la version $VERSION"

echo "release_notes<<EOF" >> $GITHUB_OUTPUT
echo "$SECTION" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT


- name: 'Créer le tag'
run: |
git tag "${{ steps.semver.outputs.tag }}"
Expand Down
89 changes: 48 additions & 41 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: 'Lancer les Tests Backend et Frontend'
name: 'Tests Backend et Frontend'

on:
pull_request:
Expand All @@ -9,56 +9,63 @@ on:
- dev

jobs:
test-backend-frontend:
test-backend:
name: 'Tests Backend'
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18] # adapte selon la version Node de ton projet

services:
mongodb:
image: mongo:7
ports:
- 27017:27017

steps:
- name: 'Checkout code'
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: 'Setup Node.js'
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 20.9.0
node-version: '20'
cache: 'npm'
cache-dependency-path: saintBarthVolleyApp/backend/package-lock.json

# ----------------------
# Backend
# ----------------------
- name: 'Installer les dépendances backend'
run: |
echo "Installation des dépendances backend"
cd saintBarthVolleyApp/backend
npm install
- name: 'Installer les dépendances'
run: npm ci
working-directory: saintBarthVolleyApp/backend

- name: 'Lancer les tests backend'
run: |
echo "Lancement des tests backend"
cd saintBarthVolleyApp/backend
npm test
run: npm test
working-directory: saintBarthVolleyApp/backend
env:
NODE_ENV: test
MONGO_URI: mongodb://localhost:27017/sbv_test
JWT_SECRET: test_secret_ci
PORT: 5000

test-frontend:
name: 'Build Frontend (vérification)'
runs-on: ubuntu-latest

steps:
- name: 'Checkout code'
uses: actions/checkout@v4

# ----------------------
# Frontend
# ----------------------
- name: 'Installer les dépendances frontend'
run: |
echo "Installation des dépendances frontend"
cd saintBarthVolleyApp/frontend
npm install
- name: 'Setup Node.js'
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: saintBarthVolleyApp/frontend/package-lock.json

- name: 'Lancer les tests frontend'
run: |
echo "Lancement des tests frontend"
cd saintBarthVolleyApp/frontend
npm test
- name: 'Installer les dépendances'
run: npm ci
working-directory: saintBarthVolleyApp/frontend

# ----------------------
# Optional: build frontend
# ----------------------
- name: 'Build frontend pour vérification'
run: |
echo "Building du frontend"
cd saintBarthVolleyApp/frontend
npm run build || { echo "❌ Build frontend échoué"; exit 1; }
- name: 'Build Next.js'
run: npm run build
working-directory: saintBarthVolleyApp/frontend
env:
# Pas de basePath en CI, pas besoin de l'URL de prod
NEXT_BASE_PATH: ''
NEXT_PUBLIC_API_URL: ''
Loading