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
167 changes: 167 additions & 0 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
# GitHub Actions Workflows

Este directorio contiene los workflows de CI/CD para el proyecto Base Angular App.

## 📁 Workflows Disponibles

### 1. `ci.yml` - Continuous Integration
**Ejecuta:** En cada push o pull request a `main` o `develop`

**Tareas:**
- ✅ Instala dependencias
- 🔍 Lint del código (si está configurado)
- 🧪 Ejecuta tests
- 🏗️ Construye la aplicación para producción
- 📊 Muestra información del build
- 📦 Genera artifacts (dist + deployment package)
- 💾 Guarda artifacts por 30 días

**Artifacts generados:**
- `angular-app-dist-{sha}`: Carpeta dist completa
- `deployment-package-{sha}`: ZIP listo para desplegar

### 2. `deploy.yml` - Prepare Release
**Ejecuta:**
- Manualmente desde GitHub Actions UI
- Automáticamente al crear un tag (v1.0.0, v2.1.0, etc.)

**Tareas:**
- 🏗️ Build de producción
- 📦 Genera paquetes TAR.GZ y ZIP
- 🔐 Crea checksums SHA256
- 📋 Incluye nginx.conf
- 🚀 Crea GitHub Release (si es un tag)
- 💾 Guarda artifacts por 90 días

## 🔐 Configuración (Opcional)

Los workflows de CI funcionan sin configuración adicional. No necesitas configurar secrets a menos que quieras automatizar despliegues a servicios específicos.

### Para Auto-Deploy (Opcional)

Si quieres desplegar automáticamente a servicios cloud, puedes agregar secrets según el servicio:

**Digital Ocean:**
- `DO_API_TOKEN`: Token de API de Digital Ocean

**AWS:**
- `AWS_ACCESS_KEY_ID`: Access Key de AWS
- `AWS_SECRET_ACCESS_KEY`: Secret Key de AWS
- `AWS_REGION`: Región (ej: us-east-1)

**Azure:**
- `AZURE_CREDENTIALS`: JSON con credenciales de service principal

**Vercel/Netlify:**
- Conecta directamente desde su dashboard (no requiere secrets)

## 🚀 Cómo Usar

### Ejecutar Tests Automáticamente
```bash
# Los tests se ejecutan automáticamente en cada push/PR
git push origin develop
```

### Desplegar Manualmente
1. Ve a la pestaña "Actions" en GitHub
2. Selecciona "CD - Deploy to Server"
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The workflow name referenced here is incorrect. According to the deploy.yml file, the workflow is named "CD - Prepare Release", not "CD - Deploy to Server". This inconsistency could confuse users trying to follow the documentation.

Suggested change
2. Selecciona "CD - Deploy to Server"
2. Selecciona "CD - Prepare Release"

Copilot uses AI. Check for mistakes.
3. Click en "Run workflow"
4. Selecciona la rama y confirma

### Desplegar Automáticamente
```bash
# Simplemente haz push a main
git push origin main
```1. Crear Pull Request (Desarrollo)
```bash
# Crea una rama feature
git checkout -b feature/nueva-funcionalidad

# Haz tus cambios y commity un resumen al final
- Recibirás notificaciones por email si algún workflow falla
- Los artifacts se pueden descargar desde la página del workflow
Comment on lines +76 to +83
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line appears to be a documentation fragment that's improperly placed. Line 76 starts with "```1. Crear Pull Request (Desarrollo)" which seems to be part of a code block that wasn't properly closed on line 75, followed by what looks like the start of a new numbered list. This creates a malformed markdown structure. The content from line 76-83 appears incomplete and should be properly formatted or removed.

Copilot uses AI. Check for mistakes.

## 🌐 Opciones de Deployment

Ver [DEPLOYMENT-CLOUD.md](../../DEPLOYMENT-CLOUD.md) para guías detalladas de deployment en:

- 🌊 **Digital Ocean** (App Platform o Droplet)
- ☁️ **AWS S3 + CloudFront**
- 🔷 **Azure Static Web Apps**
- ▲ **Vercel** (recomendado para simplicidad)
- 🌐 **Netlify**
- 📄 **GitHub Pages** (gratis para repos públicos)

## 🔧 Troubleshooting

### Los tests fallan en GitHub pero pasan localmente
- Verifica que no dependas de configuraciones locales
- Asegúrate de que todos los assets de test estén en el repo
- Revisa las versiones de Node.js (workflow usa 20.x)

### Build falla
- Verifica que todas las dependencias estén en `package.json`
- Revisa los logs en la pestaña Actions
- Prueba el build localmente: `npm ci && npm run build`

### No se generan artifacts
- Verifica que el build complete exitosamente
- Los artifacts solo se generan si todos los pasos anteriores pasan
- Artifacts de CI duran 30 días, artifacts de release duran 90 días

### Error al crear Release
- Solo se crean releases automáticas para tags que empiecen con "v"
- Verifica que tengas permisos de escritura en el repo
- El token `GITHUB_TOKEN` debe tener permiso para crear releases

## 📝 Notas

- **Artifacts de CI**: Se mantienen por 30 días
- **Artifacts de Release**: Se mantienen por 90 días
- **GitHub Releases**: Permanentes (hasta que se borren manualmente)
- Los workflows de CI se ejecutan en pull requests sin acceso a secrets (por seguridad)
- El deployment es siempre manual o mediante releases para mejor control
git pull origin main
git tag -a v1.0.0 -m "Release version 1.0.0"
git push origin v1.0.0
```

Esto:
- 🏗️ Construye la aplicación
- 📦 Crea paquetes de deployment
- 🚀 Genera un GitHub Release con todos los assets
- 📋 Incluye instrucciones de deploy para cada plataforma

### 4. Descargar y Desplegar

**Opción A: Desde GitHub Release (para tags)**
1. Ve a la sección "Releases" en GitHub
2. Descarga el archivo que necesites:
- `.tar.gz` para Linux/Mac
- `.zip` para Windows
3. Sigue las instrucciones de deployment en [DEPLOYMENT-CLOUD.md](../../DEPLOYMENT-CLOUD.md)

**Opción B: Desde Artifacts (cualquier commit)**
1. Ve a la pestaña "Actions" en GitHub
2. Selecciona el workflow ejecutado
3. Descarga el artifact `deployment-package-{sha}`
4. Úsalo para desplegar en tu servicio cloud preferido

### 5. Deploy Manual (sin tag)
```bash
# Ejecuta el workflow manualmente
# Ve a Actions → CD - Prepare Release → Run workflow
# Especifica una versión (ej: v1.1.0-beta) de tu archivo `nginx.conf`
- Ejecuta `sudo nginx -t` en el servidor para verificar

### Build falla
- Verifica que todas las dependencias estén en `package.json`
- Revisa los logs en la pestaña Actions para más detalles

## 📝 Notas

- Los artifacts de build se mantienen por 7 días
- Cada despliegue crea un backup automático con timestamp
- El workflow de CI no despliega, solo valida el código
- El workflow de CD requiere que CI pase exitosamente
Comment on lines +125 to +167
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section is malformed. Lines 125-128 appear to be incomplete git commands without a proper opening to the code block or context. Line 155 ends abruptly mid-sentence ("de tu archivo nginx.conf") and continues directly into a bulleted list on line 156. Additionally, there's a duplicate "Notas" section (first at line 118, second at line 162) with conflicting information about artifact retention (30 days vs 7 days). This entire section from lines 125-167 needs to be restructured and clarified.

Copilot uses AI. Check for mistakes.
88 changes: 88 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: CI - Build and Test

on:
push:
branches: [ main, develop, release/* ]
pull_request:
branches: [ main, develop, release/* ]

jobs:
build-and-test:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [20.x]

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

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

- name: Install dependencies
run: npm ci

- name: TypeScript syntax check
run: npm run typecheck

- name: Run tests
run: npm test -- --watch=false

- name: Build application for production
run: npm run build

- name: Display build output structure
run: |
echo " Build completed successfully!"
echo "Build output structure:"
ls -lah dist/
if [ -d "dist/base-angular-app/browser" ]; then
echo "Browser bundle size:"
du -sh dist/base-angular-app/browser
fi

- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: angular-app-dist-${{ github.sha }}
path: dist/
retention-days: 30
compression-level: 9

- name: Create deployment package
run: |
cd dist
zip -r ../angular-app-${{ github.sha }}.zip .
cd ..
echo " Package size: $(du -h angular-app-${{ github.sha }}.zip | cut -f1)"

- name: Upload deployment package
uses: actions/upload-artifact@v4
with:
name: deployment-package-${{ github.sha }}
path: angular-app-${{ github.sha }}.zip
retention-days: 30

- name: Summary
run: |
echo "### Build Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- **Commit:** ${{ github.sha }}" >> $GITHUB_STEP_SUMMARY
echo "- **Branch:** ${{ github.ref_name }}" >> $GITHUB_STEP_SUMMARY
echo "- **Node Version:** ${{ matrix.node-version }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo " **Artifacts generated:**" >> $GITHUB_STEP_SUMMARY
echo "- angular-app-dist-${{ github.sha }}" >> $GITHUB_STEP_SUMMARY
echo "- deployment-package-${{ github.sha }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo " **Ready to deploy to:**" >> $GITHUB_STEP_SUMMARY
echo "- Digital Ocean" >> $GITHUB_STEP_SUMMARY
echo "- AWS S3 + CloudFront" >> $GITHUB_STEP_SUMMARY
echo "- Azure Static Web Apps" >> $GITHUB_STEP_SUMMARY
echo "- Vercel" >> $GITHUB_STEP_SUMMARY
echo "- Netlify" >> $GITHUB_STEP_SUMMARY
142 changes: 142 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
name: CD - Prepare Release

# Este workflow prepara releases que pueden desplegarse en cualquier servicio cloud
# (Digital Ocean, AWS, Azure, Vercel, Netlify, etc.)

on:
workflow_dispatch: # Ejecución manual desde GitHub UI
inputs:
version:
description: 'Release version (e.g., v1.0.0)'
required: false
default: 'latest'
push:
tags:
- 'v*' # Se activa cuando creas un tag como v1.0.0

jobs:
prepare-release:
runs-on: ubuntu-latest

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

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Build for production
run: npm run build

- name: Get version
id: version
run: |
if [ "${{ github.event.inputs.version }}" != "" ]; then
echo "version=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
elif [ "${{ github.ref_type }}" == "tag" ]; then
echo "version=${{ github.ref_name }}" >> $GITHUB_OUTPUT
else
echo "version=latest" >> $GITHUB_OUTPUT
fi

- name: Create deployment package
run: |
cd dist
tar -czf ../angular-app-${{ steps.version.outputs.version }}.tar.gz .
zip -r ../angular-app-${{ steps.version.outputs.version }}.zip .
cd ..
echo "📦 Package created:"
ls -lh angular-app-${{ steps.version.outputs.version }}.*

- name: Generate checksums
run: |
sha256sum angular-app-${{ steps.version.outputs.version }}.tar.gz > checksums.txt
sha256sum angular-app-${{ steps.version.outputs.version }}.zip >> checksums.txt
cat checksums.txt

- name: Upload release artifacts
uses: actions/upload-artifact@v4
with:
name: release-${{ steps.version.outputs.version }}
path: |
angular-app-${{ steps.version.outputs.version }}.tar.gz
angular-app-${{ steps.version.outputs.version }}.zip
checksums.txt
nginx.conf
retention-days: 90

- name: Create GitHub Release
if: github.ref_type == 'tag'
uses: softprops/action-gh-release@v1
with:
files: |
angular-app-${{ steps.version.outputs.version }}.tar.gz
angular-app-${{ steps.version.outputs.version }}.zip
checksums.txt
nginx.conf
Comment on lines +71 to +82
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The workflow attempts to include an nginx.conf file in the artifacts (line 71) and GitHub release (line 82), but this file doesn't exist in the repository. This will cause the workflow to fail when it tries to upload these files. Either create the nginx.conf file in the repository root, or remove references to it from the workflow.

Copilot uses AI. Check for mistakes.
body: |
## 🚀 Release ${{ steps.version.outputs.version }}

### 📦 Assets
- `angular-app-${{ steps.version.outputs.version }}.tar.gz` - Producción (Linux/Mac)
- `angular-app-${{ steps.version.outputs.version }}.zip` - Producción (Windows/Universal)
- `nginx.conf` - Configuración de Nginx
- `checksums.txt` - SHA256 checksums

### 🌐 Deploy Options

**Digital Ocean App Platform:**
```bash
doctl apps create --spec .do/app.yaml
```

**Digital Ocean Droplet:**
```bash
scp angular-app-${{ steps.version.outputs.version }}.tar.gz user@droplet:/tmp/
ssh user@droplet
cd /var/www/html
tar -xzf /tmp/angular-app-${{ steps.version.outputs.version }}.tar.gz
```

**AWS S3 + CloudFront:**
```bash
unzip angular-app-${{ steps.version.outputs.version }}.zip
aws s3 sync . s3://your-bucket-name/ --delete
aws cloudfront create-invalidation --distribution-id YOUR_DIST_ID --paths "/*"
```

**Azure Static Web Apps:**
```bash
az staticwebapp deploy --name your-app-name --source angular-app-${{ steps.version.outputs.version }}.zip
```
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Summary
run: |
echo "### 🎉 Release Preparado" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Versión:** ${{ steps.version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### 📦 Archivos Generados" >> $GITHUB_STEP_SUMMARY
echo \`\`\`" >> $GITHUB_STEP_SUMMARY
ls -lh angular-app-* checksums.txt nginx.conf
echo \`\`\`" >> $GITHUB_STEP_SUMMARY
Comment on lines +130 to +132
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The backtick escaping is incorrect. Line 130 uses \``which will output literal backticks with backslashes instead of creating a code block. It should be ``` ` (three backticks without backslashes). The same issue exists on line 132.

Suggested change
echo \`\`\`" >> $GITHUB_STEP_SUMMARY
ls -lh angular-app-* checksums.txt nginx.conf
echo \`\`\`" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
ls -lh angular-app-* checksums.txt nginx.conf
echo '```' >> $GITHUB_STEP_SUMMARY

Copilot uses AI. Check for mistakes.
echo "" >> $GITHUB_STEP_SUMMARY
echo "### 🚀 Próximos Pasos" >> $GITHUB_STEP_SUMMARY
echo "1. Descarga los artifacts desde la pestaña Actions" >> $GITHUB_STEP_SUMMARY
echo "2. Elige tu plataforma de deployment:" >> $GITHUB_STEP_SUMMARY
echo " - Digital Ocean (Droplet o App Platform)" >> $GITHUB_STEP_SUMMARY
echo " - AWS S3 + CloudFront" >> $GITHUB_STEP_SUMMARY
echo " - Azure Static Web Apps" >> $GITHUB_STEP_SUMMARY
echo " - Vercel" >> $GITHUB_STEP_SUMMARY
echo " - Netlify" >> $GITHUB_STEP_SUMMARY
echo "3. Sigue las instrucciones de deployment en el README" >> $GITHUB_STEP_SUMMARY
Loading
Loading