clase:daw:daw:tema08
Diferencias
Muestra las diferencias entre dos versiones de la página.
| Revisión previa | |||
| — | clase:daw:daw:tema08 [2026/10/29 14:14] (actual) – Enlace al tema 7 entero, no a una sección claude | ||
|---|---|---|---|
| Línea 1: | Línea 1: | ||
| + | ====== 8. gh CLI ====== | ||
| + | '' | ||
| + | |||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | |||
| + | Más información: | ||
| + | * [[https:// | ||
| + | |||
| + | ===== Instalación ===== | ||
| + | Se instala con: | ||
| + | |||
| + | * **Windows**: | ||
| + | * **Linux**: '' | ||
| + | * **Mac**: '' | ||
| + | |||
| + | <sxh bash> | ||
| + | gh auth login # GitHub.com, HTTPS, navegador. Guarda también la credencial de git | ||
| + | gh auth status | ||
| + | gh auth refresh -s project | ||
| + | </ | ||
| + | |||
| + | Las órdenes de '' | ||
| + | |||
| + | ==== Issues ==== | ||
| + | GitHub ya trae la etiqueta '' | ||
| + | |||
| + | <sxh bash> | ||
| + | gh label create feature | ||
| + | </ | ||
| + | |||
| + | * Crear un issue. Responde con su URL, que acaba en su número: | ||
| + | <sxh bash> | ||
| + | gh issue create --title "Alta de clientes" | ||
| + | </ | ||
| + | * Listar los issues abiertos: | ||
| + | <sxh bash> | ||
| + | gh issue list | ||
| + | </ | ||
| + | * Ver el título, la descripción y el estado del issue 12: | ||
| + | <sxh bash> | ||
| + | gh issue view 12 | ||
| + | </ | ||
| + | * Ponerle una etiqueta: | ||
| + | <sxh bash> | ||
| + | gh issue edit 12 --add-label bug | ||
| + | </ | ||
| + | * Cerrarlo: | ||
| + | <sxh bash> | ||
| + | gh issue close 12 | ||
| + | </ | ||
| + | |||
| + | <note important> | ||
| + | |||
| + | ==== Workflows ==== | ||
| + | * Lanzar a mano un workflow que tiene '' | ||
| + | <sxh bash> | ||
| + | gh workflow run desplegar.yml | ||
| + | </ | ||
| + | * Seguir en directo el workflow que se acaba de lanzar: | ||
| + | <sxh bash> | ||
| + | gh run watch | ||
| + | </ | ||
| + | * Ver las últimas ejecuciones, | ||
| + | <sxh bash> | ||
| + | gh run list --limit 5 | ||
| + | </ | ||
| + | * Ver solo los pasos que han fallado de una ejecución: | ||
| + | <sxh bash> | ||
| + | gh run view 123456 --log-failed | ||
| + | </ | ||
| + | |||
| + | Un workflow rojo tiene un log largo y la causa está en tres líneas: '' | ||
| + | |||
| + | ===== GitHub Projects ===== | ||
| + | Un **Project** es un tablero de GitHub con los issues del repositorio como tarjetas, repartidas en columnas por su estado: //Todo//, //In Progress// y //Done//. Está en GitHub, en el menú // | ||
| + | |||
| + | {{: | ||
| + | |||
| + | ==== Crear el tablero ==== | ||
| + | |||
| + | Uno por proyecto, desde el menú '' | ||
| + | |||
| + | * En //Start from scratch//, la plantilla **Board**. | ||
| + | |||
| + | {{: | ||
| + | |||
| + | * El nombre del proyecto y, marcado, //Import items from repository// | ||
| + | |||
| + | {{: | ||
| + | |||
| + | * Sale con las tres columnas, //Todo//, //In Progress// y //Done//, las que usan los scripts. | ||
| + | |||
| + | {{: | ||
| + | |||
| + | <note important> | ||
| + | |||
| + | ==== Scripts para los issues ==== | ||
| + | |||
| + | Mover una tarjeta con '' | ||
| + | |||
| + | * **Crear un issue**: lo crea, lo añade al Project (en //Todo//) y responde con su número. La etiqueta, si no se da, es '' | ||
| + | |||
| + | <sxh bash; | ||
| + | #!/bin/bash | ||
| + | # Uso: issue_create.sh " | ||
| + | PROJECT=$(gh api graphql -F owner=' | ||
| + | |||
| + | URL=$(gh issue create --title " | ||
| + | gh project item-add $PROJECT --owner @me --url $URL > /dev/null 2>& | ||
| + | echo $URL | grep -o ' | ||
| + | </ | ||
| + | |||
| + | <sxh bash> | ||
| + | scripts/ | ||
| + | scripts/ | ||
| + | </ | ||
| + | |||
| + | \\ | ||
| + | |||
| + | * **Empezar un issue**: pasa su tarjeta a //In Progress//. | ||
| + | |||
| + | <sxh bash; | ||
| + | #!/bin/bash | ||
| + | # Uso: issue_in_progress.sh N | ||
| + | PROJECT=$(gh api graphql -F owner=' | ||
| + | N=$1 | ||
| + | |||
| + | PROJECT_ID=$(gh project view $PROJECT --owner @me --format json --jq .id) | ||
| + | CAMPO=$(gh project field-list $PROJECT --owner @me --format json --jq ' | ||
| + | OPCION=$(gh project field-list $PROJECT --owner @me --format json --jq ' | ||
| + | TARJETA=$(gh project item-list $PROJECT --owner @me --limit 1000 --format json --jq " | ||
| + | |||
| + | if [ -z " | ||
| + | |||
| + | gh project item-edit --project-id $PROJECT_ID --field-id $CAMPO --single-select-option-id $OPCION --id $TARJETA > /dev/null || { echo "No se ha podido mover la tarjeta del issue #$N"; exit 1; } | ||
| + | echo "Issue #$N en In Progress" | ||
| + | </ | ||
| + | |||
| + | <sxh bash> | ||
| + | scripts/ | ||
| + | </ | ||
| + | |||
| + | \\ | ||
| + | |||
| + | * **Cerrar un issue**: lo cierra y pasa su tarjeta a //Done//. | ||
| + | |||
| + | <sxh bash; | ||
| + | #!/bin/bash | ||
| + | # Uso: issue_close.sh N | ||
| + | PROJECT=$(gh api graphql -F owner=' | ||
| + | N=$1 | ||
| + | |||
| + | PROJECT_ID=$(gh project view $PROJECT --owner @me --format json --jq .id) | ||
| + | CAMPO=$(gh project field-list $PROJECT --owner @me --format json --jq ' | ||
| + | OPCION=$(gh project field-list $PROJECT --owner @me --format json --jq ' | ||
| + | TARJETA=$(gh project item-list $PROJECT --owner @me --limit 1000 --format json --jq " | ||
| + | |||
| + | if [ -z " | ||
| + | |||
| + | gh issue close $N > /dev/null 2>&1 | ||
| + | gh project item-edit --project-id $PROJECT_ID --field-id $CAMPO --single-select-option-id $OPCION --id $TARJETA > /dev/null || { echo "No se ha podido mover la tarjeta del issue #$N"; exit 1; } | ||
| + | echo "Issue #$N cerrado y en Done" | ||
| + | </ | ||
| + | |||
| + | <sxh bash> | ||
| + | scripts/ | ||
| + | </ | ||
| + | |||
| + | ===== Ejercicios ===== | ||
| + | |||
| + | ==== Ejercicio 1 ==== | ||
| + | * Instala '' | ||
| + | * En tu repositorio de Java, crea la etiqueta '' | ||
| + | * Lanza a mano el workflow del [[tema07# | ||
| + | |||
| + | ==== Ejercicio 2 ==== | ||
| + | * Crea el tablero del repositorio como en [[# | ||
| + | * Copia los tres scripts en la carpeta '' | ||
| + | * Crea un issue con '' | ||
