Last active
August 21, 2024 10:57
-
-
Save polsala/42a77962c7ba3496c267f12df2419252 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Configuración del repositorio | |
| OWNER="gisce" | |
| REPO="erp" | |
| GITHUB_API_URL="https://api.github.com" | |
| GITHUB_TOKEN=${GITHUB_TOKEN} | |
| MAX_PRS=150 # Definir el máximo de PRs a procesar | |
| # Almacenar las PRs que cumplen el requisito | |
| mergeable_prs=() | |
| echo "Buscando PRs con el check 'Mergeable' en estado SUCCESS..." | |
| # Obtener las primeras 150 PRs abiertas | |
| pull_requests=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \ | |
| "$GITHUB_API_URL/repos/$OWNER/$REPO/pulls?state=open&per_page=$MAX_PRS" | jq -r '.[].number') | |
| # Recorrer cada PR y verificar el estado de 'Mergeable' | |
| for pr in $pull_requests; do | |
| # Ejecutar el comando y capturar la salida | |
| mergeable_status=$(gisce_github get-pullrequest-context-check-status --owner $OWNER --repository $REPO --pr=$pr --check-name=Mergeable 2>&1) | |
| # Comprobar si el comando falló | |
| if [ $? -ne 0 ]; then | |
| continue | |
| fi | |
| if [ "$mergeable_status" == "\"SUCCESS\"" ]; then | |
| # Agregar la PR a la lista si es mergeable | |
| mergeable_prs+=($pr) | |
| fi | |
| done | |
| # Imprimir el listado final de PRs que cumplen con el requisito | |
| if [ ${#mergeable_prs[@]} -eq 0 ]; then | |
| echo "No se encontraron PRs mergeables con estado SUCCESS." | |
| else | |
| echo "PRs mergeables con estado SUCCESS:" | |
| for pr in "${mergeable_prs[@]}"; do | |
| echo "#$pr" | |
| done | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment