99 lines
3.8 KiB
YAML
99 lines
3.8 KiB
YAML
name: CI Pipeline - Quality & Build
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- develop
|
|
- main
|
|
- master
|
|
pull_request:
|
|
branches:
|
|
- develop
|
|
- main
|
|
- master
|
|
|
|
jobs:
|
|
validate-frontend:
|
|
name: Build & Validate Frontend
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout Code
|
|
run: |
|
|
git config --global --add safe.directory "*"
|
|
git init
|
|
git remote add origin https://git.bryan-bano.com/Bryan.bano/PORTFOLIO.git 2>/dev/null || git remote set-url origin https://git.bryan-bano.com/Bryan.bano/PORTFOLIO.git
|
|
git fetch --depth 1 origin ${{ github.sha }}
|
|
git checkout --force FETCH_HEAD
|
|
|
|
- name: Validate Pull Request Metadata
|
|
if: github.event_name == 'pull_request'
|
|
env:
|
|
PR_HEAD_REF: ${{ github.head_ref }}
|
|
PR_BASE_REF: ${{ github.base_ref }}
|
|
PR_TITLE: ${{ github.event.pull_request.title }}
|
|
PR_BODY: ${{ github.event.pull_request.body }}
|
|
run: |
|
|
echo "==> Validando Pull Request: '$PR_TITLE'"
|
|
echo " Rama origen: $PR_HEAD_REF -> Rama destino: $PR_BASE_REF"
|
|
|
|
if [[ "$PR_BASE_REF" == "develop" ]]; then
|
|
if ! [[ "$PR_HEAD_REF" =~ ^(feature|feat|chore|fix|bugfix|refactor|docs|test|perf)/ ]]; then
|
|
echo "❌ Error de Rama: Pull Requests hacia 'develop' deben provenir de una rama específica (feature/*, chore/*, fix/*, refactor/*, etc.)."
|
|
echo " Rama recibida: '$PR_HEAD_REF'"
|
|
exit 1
|
|
fi
|
|
elif [[ "$PR_BASE_REF" == "main" || "$PR_BASE_REF" == "master" ]]; then
|
|
if ! [[ "$PR_HEAD_REF" =~ ^(release|hotfix)/ || "$PR_HEAD_REF" == "develop" ]]; then
|
|
echo "❌ Error de Rama: Pull Requests hacia producción ('main') deben provenir de 'develop', 'release/*' o 'hotfix/*'."
|
|
echo " Rama recibida: '$PR_HEAD_REF'"
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
TITLE_REGEX="^(feat|fix|chore|docs|style|refactor|perf|test|build|ci|revert)(\([a-zA-Z0-9_\-\./]+\))?!?: .+"
|
|
if ! [[ "$PR_TITLE" =~ $TITLE_REGEX ]]; then
|
|
echo "❌ Error de Título: El título del PR debe seguir Conventional Commits."
|
|
echo " Formato: <tipo>(<ámbito opcional>): <descripción>"
|
|
echo " Ejemplos: feat(auth): add login form, fix: resolve token refresh, chore(ci): update runner"
|
|
echo " Título recibido: '$PR_TITLE'"
|
|
exit 1
|
|
fi
|
|
|
|
CLEAN_BODY=$(echo "$PR_BODY" | tr -d '[:space:]')
|
|
if [[ ${#CLEAN_BODY} -lt 15 ]]; then
|
|
echo "❌ Error de Descripción: La descripción del Pull Request no puede estar vacía."
|
|
echo " Por favor explica brevemente qué cambios incluye este PR para facilitar la revisión."
|
|
exit 1
|
|
fi
|
|
|
|
echo "✅ Validaciones de Pull Request aprobadas."
|
|
|
|
- name: Scan for Leaked Secrets & Credentials
|
|
run: |
|
|
ARCH=$(uname -m)
|
|
case "$ARCH" in
|
|
x86_64) GITLEAKS_ARCH="x64" ;;
|
|
aarch64|arm64) GITLEAKS_ARCH="arm64" ;;
|
|
*) GITLEAKS_ARCH="x64" ;;
|
|
esac
|
|
|
|
mkdir -p /tmp/bin
|
|
if ! command -v gitleaks &> /dev/null; then
|
|
echo "Descargando Gitleaks para $ARCH ($GITLEAKS_ARCH)..."
|
|
curl -sSL "https://github.com/gitleaks/gitleaks/releases/download/v8.18.4/gitleaks_8.18.4_linux_${GITLEAKS_ARCH}.tar.gz" | tar -xz -C /tmp/bin gitleaks
|
|
export PATH="/tmp/bin:$PATH"
|
|
fi
|
|
|
|
echo "Ejecutando escaneo de credenciales y secretos..."
|
|
gitleaks detect --source . --verbose --no-git
|
|
|
|
- name: Install Frontend Dependencies
|
|
run: |
|
|
cd src/frontend
|
|
npm ci
|
|
|
|
- name: Build Angular 20 Production Bundle
|
|
run: |
|
|
cd src/frontend
|
|
npm run build -- --configuration production
|