backend-mcp
Version:
Generador automático de backends con Node.js, Express, Prisma y módulos configurables. Servidor MCP compatible con npx para agentes IA. Soporta PostgreSQL, MySQL, MongoDB y SQLite.
247 lines (191 loc) • 4.79 kB
Markdown
# 📦 Módulo ci
**Versión:** 1.0.0
**Categoría:** devops
**Descripción:** Sistema completo de CI/CD con GitHub Actions, GitLab CI y pipelines automatizados
## 📊 Estado del Módulo
| Componente | Estado |
|------------|--------|
| Script de inicialización | ✅ Disponible |
| Templates | ❌ Faltante |
| Ejemplos | ❌ Faltante |
## 🔗 Dependencias
### Opcionales
- `docker`
- `testing`
- `logging`
- `database`
## 🤖 Triggers para IA
Este módulo se activa automáticamente cuando se detectan las siguientes palabras clave:
- **needs_cicd**: true
- **wants_automation**: true
- **deployment_pipeline**: true
- **testing_automation**: true
- **code_quality_checks**: true
## ✨ Características
- automated-testing
- code-quality-analysis
- security-scanning
- dependency-vulnerability-check
- automated-deployment
- rollback-capabilities
- environment-promotion
- notification-system
- artifact-management
- cache-optimization
- parallel-execution
- conditional-workflows
## 📖 Documentación Completa
# Módulo CI/CD
Módulo para configuración de integración continua y despliegue continuo en proyectos backend.
## Características
- ✅ Configuración automática de GitHub Actions
- ✅ Pipeline de testing automatizado
- ✅ Despliegue automático a staging/producción
- ✅ Validación de código con ESLint y Prettier
- ✅ Análisis de seguridad con npm audit
- ✅ Notificaciones de estado del build
## Configuración
### Requisitos
- Node.js 16+
- Repositorio Git configurado
- Acceso a GitHub Actions (para GitHub)
### Variables de Entorno
```bash
# Configuración del CI/CD
CI_PROVIDER=github # github, gitlab, jenkins
DEPLOY_ENVIRONMENT=staging # staging, production
NOTIFY_SLACK_WEBHOOK=https://hooks.slack.com/...
```
## Uso
### Configuración Básica
```javascript
const { initCI } = require('./modules/ci');
// Configurar CI/CD básico
await initCI({
provider: 'github',
environment: 'staging',
notifications: {
slack: process.env.NOTIFY_SLACK_WEBHOOK
}
});
```
### Pipeline Personalizado
```javascript
// Configurar pipeline personalizado
await initCI({
provider: 'github',
pipeline: {
test: true,
lint: true,
security: true,
deploy: {
staging: true,
production: false
}
}
});
```
## Archivos Generados
- `.github/workflows/ci.yml` - Pipeline principal de CI/CD
- `.github/workflows/deploy.yml` - Workflow de despliegue
- `scripts/deploy.sh` - Script de despliegue
- `docker-compose.ci.yml` - Configuración para testing
## Ejemplos
### GitHub Actions Básico
```yaml
name: CI/CD Pipeline
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
- run: npm ci
- run: npm test
- run: npm run lint
```
### Despliegue Automático
```yaml
deploy:
needs: test
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- name: Deploy to staging
run: |
echo "Deploying to staging..."
# Comandos de despliegue
```
## Configuración Avanzada
### Múltiples Entornos
```javascript
await initCI({
environments: {
staging: {
branch: 'develop',
url: 'https://staging.example.com'
},
production: {
branch: 'main',
url: 'https://example.com',
requiresApproval: true
}
}
});
```
### Notificaciones
```javascript
await initCI({
notifications: {
slack: {
webhook: process.env.SLACK_WEBHOOK,
channel: '#deployments'
},
email: {
recipients: ['team@example.com'],
onFailure: true
}
}
});
```
## Troubleshooting
### Errores Comunes
1. **Pipeline falla en tests**
- Verificar que todas las dependencias estén instaladas
- Revisar variables de entorno requeridas
2. **Despliegue falla**
- Verificar credenciales de despliegue
- Comprobar conectividad con el servidor
3. **Notificaciones no llegan**
- Verificar webhook de Slack
- Comprobar configuración de email
### Logs y Debugging
```bash
# Ver logs del último despliegue
npm run ci:logs
# Ejecutar pipeline localmente
npm run ci:local
# Validar configuración
npm run ci:validate
```
## Contribuir
Para contribuir a este módulo:
1. Fork el repositorio
2. Crea una rama para tu feature
3. Añade tests para nuevas funcionalidades
4. Ejecuta `npm test` para verificar
5. Crea un Pull Request
## Licencia
MIT License - ver archivo LICENSE para más detalles.
## 🔗 Enlaces
- [Volver al índice de módulos](./README.md)
- [Documentación principal](../README.md)
- [Código fuente](../../modules/ci/)