From c20733afc391fd7d0204f7e2b1e1edf21e3164bc Mon Sep 17 00:00:00 2001 From: Hanzo_dev <2002samudiojohan@gmail.com> Date: Sun, 22 Feb 2026 16:50:56 -0500 Subject: [PATCH] ci: add GitHub Actions workflow for automatic Firebase frontend deploy --- .github/workflows/deploy-frontend.yml | 57 +++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 .github/workflows/deploy-frontend.yml diff --git a/.github/workflows/deploy-frontend.yml b/.github/workflows/deploy-frontend.yml new file mode 100644 index 0000000..83c3492 --- /dev/null +++ b/.github/workflows/deploy-frontend.yml @@ -0,0 +1,57 @@ +name: 🚀 Deploy Frontend → Firebase Hosting + +# Se activa en cada push a la rama main +# SOLO cuando hay cambios en el frontend (no re-despliega si solo cambió el backend) +on: + push: + branches: + - main + paths: + - 'frontend/**' + - '.github/workflows/deploy-frontend.yml' + +jobs: + build-and-deploy: + name: Build & Deploy a Firebase + runs-on: ubuntu-latest + defaults: + run: + working-directory: frontend + + steps: + # 1. Clonar el repositorio + - name: 📥 Checkout del repositorio + uses: actions/checkout@v4 + + # 2. Configurar Node.js + - name: ⚙️ Setup Node.js 22 + uses: actions/setup-node@v4 + with: + node-version: '22' + cache: 'npm' + cache-dependency-path: frontend/package-lock.json + + # 3. Instalar dependencias + - name: 📦 Instalar dependencias (npm ci) + run: npm ci + + # 4. Crear el archivo .env.production con las variables del repositorio + # Estas variables las defines en: GitHub → Settings → Secrets and variables → Actions + - name: 🔐 Crear .env.production desde GitHub Secrets + run: | + echo "VITE_API_URL=${{ secrets.VITE_API_URL }}" > .env.production + echo "VITE_GOOGLE_MAPS_API_KEY=${{ secrets.VITE_GOOGLE_MAPS_API_KEY }}" >> .env.production + + # 5. Compilar el frontend para producción + - name: 🔨 Build de producción (Vite) + run: npm run build + + # 6. Deploy a Firebase Hosting + - name: 🚀 Deploy a Firebase Hosting + uses: FirebaseExtended/action-hosting-deploy@v0 + with: + repoToken: ${{ secrets.GITHUB_TOKEN }} + firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT }} + channelId: live + projectId: sibu2-0-transport-2026 + entryPoint: './frontend'