Skip to content

Mejoras en la asignación de profesores #162

Mejoras en la asignación de profesores

Mejoras en la asignación de profesores #162

Workflow file for this run

name: Flutter CI
on:
pull_request:
branches: [ develop, main ]
push:
branches: [ develop ]
permissions:
contents: read
issues: write
jobs:
build:
runs-on: ubuntu-latest
steps:
# 1️⃣ Checkout del repositorio
- name: Checkout repo
uses: actions/checkout@v4
# 2️⃣ Configurar Flutter
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '3.35.5'
# 3️⃣ Instalar dependencias
- name: Install dependencies
run: flutter pub get
# 4️⃣ Analizar código
- name: Analyze code
run: flutter analyze
# 5️⃣ Ejecutar tests
- name: Run tests
run: flutter test
# 6️⃣ Reportar fallos a Issues automáticamente
- name: 🤖 Report Failure to Issues
if: failure()
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: ${{ github.ref_name }}
SHA: ${{ github.sha }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
ACTOR: ${{ github.actor }}
run: |
TITLE="🚨 CI Failure: Build falló en rama '$BRANCH'"
LABEL="ci-failure"
BODY="### ❌ El CI ha fallado
**Rama:** \`$BRANCH\`
**Commit:** \`$SHA\`
**Autor del Push:** @$ACTOR
🔍 **[Ver Logs del Error]($RUN_URL)**
Por favor revisa el código y soluciona los errores reportados por 'flutter analyze' o 'flutter test'."
# Crear etiqueta si no existe
if ! gh label list | grep -q "$LABEL"; then
echo "La etiqueta '$LABEL' no existe. Creándola..."
gh label create "$LABEL" --color "d73a4a" --description "Fallo automático del CI" || echo "Aviso: No se pudo crear la etiqueta."
fi
# Buscar issue abierto con este título
EXISTING_ISSUE=$(gh issue list --search "$TITLE in:title state:open" --limit 1 --json number --jq '.[0].number')
if [ -z "$EXISTING_ISSUE" ]; then
echo "Creando nuevo Issue..."
gh issue create \
--title "$TITLE" \
--body "$BODY" \
--label "$LABEL" \
--assignee "$ACTOR"
else
echo "Actualizando Issue #$EXISTING_ISSUE..."
gh issue comment $EXISTING_ISSUE \
--body "⚠️ **Nueva falla detectada** en el commit \`$SHA\`. Revisa los [nuevos logs aquí]($RUN_URL)."
fi
# 7️⃣ Cerrar issue si todo pasa
- name: ✅ Close CI Issue if build succeeds
if: success()
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: ${{ github.ref_name }}
run: |
TITLE="🚨 CI Failure: Build falló en rama '$BRANCH'"
# Buscar issue abierto
EXISTING_ISSUE=$(gh issue list --search "$TITLE in:title state:open" --limit 1 --json number --jq '.[0].number')
if [ -n "$EXISTING_ISSUE" ]; then
echo "Cerrando Issue #$EXISTING_ISSUE porque el CI pasó ✅"
gh issue comment $EXISTING_ISSUE --body "✅ CI pasó correctamente, cerrando este issue automáticamente."
gh issue close $EXISTING_ISSUE
else
echo "No hay issue de fallo de CI abierto para cerrar."
fi