Skip to content

📝 Docs: Actualizar README con logo #261

📝 Docs: Actualizar README con logo

📝 Docs: Actualizar README con logo #261

Workflow file for this run

name: Flutter CI
on:
pull_request:
branches: [ develop, main ]
push:
branches: [ develop, main ]
permissions:
contents: write
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️⃣ Build APK SOLO en main
- name: Build APK
if: github.ref == 'refs/heads/main'
run: flutter build apk --release
# 7️⃣ Subir APK como artifact SOLO en main
- name: Upload APK Artifact
if: github.ref == 'refs/heads/main'
uses: actions/upload-artifact@v4
with:
name: app-release
path: build/app/outputs/flutter-apk/app-release.apk
# 8️⃣ Crear Release SOLO en main
- name: Create GitHub Release
if: github.ref == 'refs/heads/main'
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ github.run_number }}
name: "Build #${{ github.run_number }}"
files: build/app/outputs/flutter-apk/app-release.apk
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# 9️⃣ 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
# 🔟 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
# 1️⃣1️⃣ Build Web SOLO en main (Estrategia Pre-compilado)
- name: Build Flutter Web
if: github.ref == 'refs/heads/main'
run: flutter build web --release --base-href /
# 1️⃣1️⃣.5️⃣ Copiar identidad del proyecto a la carpeta de build
- name: Copy Vercel Identity
if: github.ref == 'refs/heads/main'
run: cp -r .vercel build/web/
# 1️⃣2️⃣ Desplegar a Vercel con IDs forzados
- name: Deploy to Vercel
if: github.ref == 'refs/heads/main'
uses: amondnet/vercel-action@v20
with:
vercel-token: ${{ secrets.VERCEL_TOKEN }}
vercel-org-id: ${{ secrets.VERCEL_ORG_ID }}
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }}
working-directory: ./build/web
vercel-args: '--prod --force'