github-actions

Configura GitHub Actions con detección proactiva de repos sin CI.


Triggers

Frases que activan el skill
“agregar CI”
“setup GitHub Actions”
“crear workflow”
“deploy workflow”
“automatizar tests”
“CI/CD pipeline”

Detección proactiva

Al iniciar trabajo en un proyecto, el skill verifica si existe .github/workflows/:

ls -la .github/workflows/ 2>/dev/null || echo "NO_WORKFLOWS"

Si no hay workflows → pregunta si querés agregar CI básico.


Workflow del skill

1. Actualización de conocimiento

Antes de generar, verificar versiones actuales:

Action Versión actual
actions/checkout v4
actions/setup-node v4
actions/setup-python v5
actions/setup-go v5
actions/cache v4

2. Detección de stack

# Tipo de proyecto
ls package.json && echo "NODE"
ls pyproject.toml && echo "PYTHON"
ls go.mod && echo "GO"

# Package manager (Node.js)
ls pnpm-lock.yaml && echo "PNPM"
ls bun.lockb && echo "BUN"
ls package-lock.json && echo "NPM"

3. Análisis de scripts (Node.js)

Lee package.json y detecta scripts disponibles:

  • lint → Incluir linting
  • typecheck → Incluir type checking
  • test → Incluir testing
  • build → Incluir build
  • test:coverage → Incluir coverage upload

4. Selección de workflows

Node.js:

  • CI Básico (lint, typecheck, test, build)
  • Deploy a GitHub Pages
  • Release con Tags (v*)
  • Security Scans
  • Coverage Upload (Codecov)

Python:

  • CI Básico (ruff, pyright/mypy, pytest)
  • Coverage Upload

Go:

  • CI Básico (go vet, golangci-lint, go test)
  • Release binaries

Anti-patterns detectados

Anti-Pattern Fix
actions/*@v3 Actualizar a @v4
setup-node sin cache Agregar cache: 'npm'
npm install Usar npm ci
Sin concurrency: Agregar control
Matrix con una versión Remover matrix innecesario

Best practices aplicadas

  1. Últimas versiones de actions (@v4)
  2. npm ci para builds reproducibles
  3. Caching en setup-node/python/go
  4. Concurrency control para cancelar runs outdated
  5. fail-fast: true para cancelar jobs paralelos
  6. Permissions explícitos cuando se necesitan
  7. Node 22.x (LTS actual)

Concurrency control

Siempre incluido:

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}

Cancela runs de PR desactualizados pero nunca cancela main.


Package manager detection

Lockfile Package Manager Install Command
pnpm-lock.yaml pnpm pnpm install --frozen-lockfile
bun.lockb bun bun install --frozen-lockfile
package-lock.json npm npm ci

Output

Workflows Created/Updated
=========================

✓ .github/workflows/ci.yml
  - Triggers: push (main), pull_request
  - Jobs: lint, typecheck, test, build
  - Node: 22.x with npm

Next Steps:
1. Review generated workflows
2. git add .github/workflows/
3. git commit -m "ci: add GitHub Actions workflow"
4. Push to trigger first run

Validación

Si actionlint está disponible:

actionlint .github/workflows/*.yml

Herramientas disponibles

  • Bash - Ejecutar comandos, detectar stack
  • Read - Leer package.json
  • Write - Crear workflows
  • Edit - Modificar workflows existentes
  • Glob - Buscar archivos
  • Grep - Buscar patrones
  • WebSearch - Verificar versiones actuales
  • Context7 - Documentación actualizada