ci: add GitHub Actions workflow for automatic Firebase frontend deploy
This commit is contained in:
57
.github/workflows/deploy-frontend.yml
vendored
Normal file
57
.github/workflows/deploy-frontend.yml
vendored
Normal file
@ -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'
|
||||
Reference in New Issue
Block a user