🔄 Flujo Completo con Linter
Crear Feature Branch
Empezar desde main actualizado
git checkout main
git pull origin main
git checkout -b feature/nueva-funcionalidad
git pull origin main
git checkout -b feature/nueva-funcionalidad
Desarrollar CĂłdigo
Escribir cĂłdigo con linter local activo
# Linter en tiempo real (VS Code)
npm run lint:watch
# Commit con pre-commit hooks
git add .
git commit -m "feat: add login form"
npm run lint:watch
# Commit con pre-commit hooks
git add .
git commit -m "feat: add login form"
âś… Linter local: Passed
Push & CI Trigger
Push dispara checks automáticos
git push -u origin feature/nueva-funcionalidad
# GitHub Actions ejecuta:
# - Linter
# - Tests
# - Type checking
# - Security scan
# GitHub Actions ejecuta:
# - Linter
# - Tests
# - Type checking
# - Security scan
⏳ CI running...
Crear Pull Request
PR con status checks requeridos
# En GitHub.com:
# 1. Compare & pull request
# 2. Ver status checks
# 3. Asignar reviewers
# 1. Compare & pull request
# 2. Ver status checks
# 3. Asignar reviewers
âś… All checks passed
Review + Linter Fixes
Si hay issues, fix y push automáticamente
# Si linter falla:
npm run lint:fix
git add .
git commit -m "fix: resolve linting issues"
git push
# Re-run checks automáticamente
npm run lint:fix
git add .
git commit -m "fix: resolve linting issues"
git push
# Re-run checks automáticamente
❌ Linting failed → Fix required
Merge Automático
Solo merge si todos los checks pasan
# Branch protection rules:
# âś… Linter must pass
# âś… Tests must pass
# âś… Review approved
# → Auto-merge enabled
# âś… Linter must pass
# âś… Tests must pass
# âś… Review approved
# → Auto-merge enabled
âś… Ready to merge
Deploy & Cleanup
Auto-tag, release y limpieza
# Auto-ejecuta:
# 1. Auto-tag (v1.2.3)
# 2. Docker build & push
# 3. Deploy to production
# Cleanup local:
git checkout main
git pull origin main
git branch -d feature/nueva-funcionalidad
# 1. Auto-tag (v1.2.3)
# 2. Docker build & push
# 3. Deploy to production
# Cleanup local:
git checkout main
git pull origin main
git branch -d feature/nueva-funcionalidad
🚀 Deployed successfully
⚙️ CI Workflow
# .github/workflows/ci.yml
name: CI
on:
pull_request:
branches: [main]
push:
branches: [main]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- run: npm ci
- run: npm run lint
- run: npm test
name: CI
on:
pull_request:
branches: [main]
push:
branches: [main]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- run: npm ci
- run: npm run lint
- run: npm test
đź”’ Branch Protection
Settings → Branches → Add rule
- âś… Require status checks to pass
- âś… Require branches to be up to date
- âś… Require pull request reviews
- âś… Dismiss stale reviews
- âś… Restrict pushes to main
🎯 Pre-commit Hooks
# .husky/pre-commit
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
npm run lint
npm run test
npm run type-check
# package.json
{
"scripts": {
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"prepare": "husky install"
}
}
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
npm run lint
npm run test
npm run type-check
# package.json
{
"scripts": {
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"prepare": "husky install"
}
}
🚀 Auto-merge Setup
# GitHub CLI
gh pr merge --auto --squash
# O en GitHub.com:
# 1. Enable auto-merge
# 2. Select merge method
# 3. Merge when ready
# Requiere:
# - All checks pass âś…
# - Reviews approved âś…
# - Branch up to date âś…
gh pr merge --auto --squash
# O en GitHub.com:
# 1. Enable auto-merge
# 2. Select merge method
# 3. Merge when ready
# Requiere:
# - All checks pass âś…
# - Reviews approved âś…
# - Branch up to date âś…
đź’ˇ Tips Pro para Linter + GitHub Flow
đź”§ Setup Local
Configura linter en VS Code para feedback inmediato mientras escribes cĂłdigo.
⚡ Pre-commit Hooks
Usa Husky para ejecutar linter antes de cada commit. Evita pushes con errores.
🎯 Draft PRs
Crea PRs como draft para CI feedback temprano sin notificar reviewers.
🔄 Auto-fix
Configura scripts para auto-fix issues menores de linting automáticamente.
📊 Status Checks
Require que todos los checks pasen antes de merge. No exceptions!
đźš« Bypass Protection
Nunca bypasses branch protection, ni siquiera para "fixes rápidos".