Files
NDF/.gitea/workflows/ci.yml
T
msaid-soighiri 1c3eaea398
CI-CD NDF Complet / test-and-quality (push) Failing after 1m5s
CI-CD NDF Complet / deploy (push) Has been skipped
Actualiser .gitea/workflows/ci.yml
2026-05-19 11:22:40 +02:00

70 lines
2.3 KiB
YAML

name: CI-CD NDF Complet
run-name: Pipeline exécuté par ${{ github.actor }}
on:
push:
branches:
- master
jobs:
test-and-quality:
runs-on: ubuntu-latest
steps:
- name: Récupération du code
uses: actions/checkout@v3
with:
fetch-depth: 0
# 1. ÉTAPE DES TESTS AUTOMATISÉE
- name: Installation et Tests Node.js (Backend)
run: |
cd ndf/public/backend
npm install
# On vérifie si le script "test" est présent dans le package.json du backend
if grep -q '"test":' package.json; then
echo "✅ Script de test trouvé ! Lancement des tests..."
npm test -- --coverage --watchAll=false
else
echo "⚠️ Aucun script de test configuré dans package.json. Passage à la suite."
fi
# 2. ÉTAPE SONARQUBE
- name: Analyse SonarQube
uses: sonarsource/sonarqube-scan-action@master
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
with:
args: >
-Dsonar.projectKey=ndf-gitea
-Dsonar.sources=ndf/public/backend
-Dsonar.javascript.lcov.reportPaths=ndf/public/backend/coverage/lcov.info
deploy:
needs: test-and-quality
runs-on: ubuntu-latest
steps:
- name: Récupération du code pour le déploiement
uses: actions/checkout@v3
# 3. CRÉATION DU FICHIER DE PORTS ALTERNATIFS POUR GITEA (Sur mesure)
- name: Configuration des ports alternatifs Gitea
run: |
cat <<EOF > docker-compose.gitea.yml
version: '3.8'
services:
backend:
ports:
- "8025:3024" # Jenkins a le 8024, Gitea prend le 8025
frontend:
ports:
- "3026:81" # Jenkins a le 3025, Gitea prend le 3026
EOF
# 4. DÉPLOIEMENT DE LA STACK ISOLÉE SANS CONFLIT
- name: Déploiement de la nouvelle Stack Gitea
run: |
# On fusionne ton compose d'origine et notre fichier de ports alternatifs
# On déploie dans la stack isolée demandée : gitea-action-dev
docker compose -f docker-compose.yml -f docker-compose.gitea.yml -p gitea-action-dev up -d --build