~/docs /GitHub Actions basico
GitHub Actions basico
GitHub Actions basico
Imported from Notion: GitHub Actions basico
updated:: 2026.07.10
Que resuelve
Guia basica para crear workflows de GitHub Actions, ejecutar tests, usar secrets y depurar errores comunes.
Estructura
Los workflows viven en:
.github/workflows/{WORKFLOW}.yml
Workflow minimo
name: CI
on:
push:
pull_request:
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Run tests
run: echo "run tests here"
Python CI
name: Python CI
on:
push:
pull_request:
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- run: python -m pip install -r requirements.txt
- run: python -m pytest
Node CI
name: Node CI
on:
push:
pull_request:
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "22"
cache: "npm"
- run: npm ci
- run: npm test
Triggers utiles
Manual
on:
workflow_dispatch:
Solo main
on:
push:
branches: ["main"]
Programado
on:
schedule:
- cron: "0 3 * * *"
Secrets
Usar secret
env:
API_TOKEN: ${{ secrets.API_TOKEN }}
En un step
- name: Call API
run: curl -H "Authorization: Bearer $API_TOKEN" https://api.example.com/ping
env:
API_TOKEN: ${{ secrets.API_TOKEN }}
warningNo imprimas secrets con
echo. GitHub intenta enmascararlos, pero no lo uses como mecanismo de seguridad.
Cache
pip
- uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: "pip"
npm
- uses: actions/setup-node@v4
with:
node-version: "22"
cache: "npm"
Artifacts
Subir artifact
- uses: actions/upload-artifact@v4
with:
name: build-output
path: dist/
Descargar artifact
- uses: actions/download-artifact@v4
with:
name: build-output
Debug
Ver contexto basico
- run: |
pwd
ls -la
git status
Activar logs de shell
- run: |
set -euxo pipefail
./scripts/test.sh
Variables
| Variable | Descripcion |
|---|---|
{WORKFLOW} | Nombre del archivo YAML |
Errores comunes
| Sintoma | Causa probable | Solucion |
|---|---|---|
| Workflow no aparece | Archivo fuera de .github/workflows | Revisa ruta y extension |
Falla npm install | Lockfile requerido | Usa npm ci |
| Secret vacio | No existe o no disponible en fork | Revisa Settings -> Secrets |
| Tests pasan local y fallan | Entorno distinto | Fija versiones y muestra logs |
Checklist final
-
Trigger correcto.
-
Versiones fijadas.
-
Secrets no impresos.
-
Cache si aporta velocidad.
-
Artifacts si necesitas descargar resultados.
- EOF -