Para ejecutar los comandos de gcloud en esta página, instala Google Cloud CLI.
Mantén a mano el código fuente de tu aplicación incluido firebase.json. Tu código fuente debe almacenarse en un repositorio, como Cloud Source Repositories, GitHub o Bitbucket.
En la tabla de permisos, busca el correo electrónico de la cuenta de servicio que usas para la compilación y haz clic en el ícono de lápiz.
Agrega los roles Cloud Build Service Account(roles/cloudbuild.builds.builder), Firebase Admin (roles/firebase.admin) y API Keys Admin (roles/serviceusage.apiKeysAdmin) a la cuenta de servicio.
Haz clic en Guardar.
Usa la imagen de Docker firebase
Cloud Build proporciona una imagen del compilador que puedes usar para invocar comandos de firebase en Cloud Build. Para usar este compilador en un archivo de configuración de Cloud Build, puedes usar el paso de compilación firebase para realizar la implementación en Firebase:
Crea un archivo de configuración de compilación llamado cloudbuild.yaml o cloudbuild.json, en el que PROJECT_ID es tu ID del proyecto deGoogle Cloud y FIREBASE_PROJECT_ID es tu ID del proyecto de Firebase:
YAML
steps:-name:"us-docker.pkg.dev/firebase-cli/us/firebase"args:['deploy','--project=FIREBASE_PROJECT_ID','--only=hosting']## Or, target a specific version of firebase-tools-name:"us-docker.pkg.dev/firebase-cli/us/firebase":x.y.zargs:['deploy','--project=FIREBASE_PROJECT_ID','--only=hosting']
CONFIG_FILE_PATH es la ruta de acceso al archivo de configuración de compilación.
SOURCE_DIRECTORY es la ruta o la URL del código fuente.
Implementación continua
Puedes automatizar la implementación del software en Firebase si creas activadores de Cloud Build. Puedes configurar activadores para compilar y, luego, implementar imágenes cada vez que actualices tu código fuente.
Para automatizar tu implementación en Firebase, haz lo siguiente:
En tu repositorio, agrega un archivo de configuración de compilación con pasos para invocar el comando firebase deploy, en el que PROJECT_ID es el ID de tu proyecto Google Cloud :
[[["Fácil de comprender","easyToUnderstand","thumb-up"],["Resolvió mi problema","solvedMyProblem","thumb-up"],["Otro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Información o código de muestra incorrectos","incorrectInformationOrSampleCode","thumb-down"],["Faltan la información o los ejemplos que necesito","missingTheInformationSamplesINeed","thumb-down"],["Problema de traducción","translationIssue","thumb-down"],["Otro","otherDown","thumb-down"]],["Última actualización: 2025-09-04 (UTC)"],[[["\u003cp\u003eThis page provides instructions on deploying applications to Firebase using Cloud Build, assuming familiarity with Cloud Build's quickstarts and build configuration.\u003c/p\u003e\n"],["\u003cp\u003eBefore deploying, you must enable the Cloud Build, Firebase, and Resource Manager APIs, and have your application source code, including \u003ccode\u003efirebase.json\u003c/code\u003e, stored in a repository.\u003c/p\u003e\n"],["\u003cp\u003eTo deploy, you need to use the Firebase community builder image, which involves building and pushing it to the Container Registry or Artifact Registry.\u003c/p\u003e\n"],["\u003cp\u003eDeployment is configured via a build config file (\u003ccode\u003ecloudbuild.yaml\u003c/code\u003e or \u003ccode\u003ecloudbuild.json\u003c/code\u003e) specifying the Firebase project and deployment details.\u003c/p\u003e\n"],["\u003cp\u003eYou can set up continuous deployment to Firebase by creating Cloud Build triggers that automatically deploy updates whenever changes are pushed to the connected repository.\u003c/p\u003e\n"]]],[],null,["This page explains how to deploy applications to\n[Firebase](https://firebase.google.com/) using\nCloud Build. If you're new to Cloud Build, read the\n[quickstarts](/build/docs/quickstarts) and the\n[Build configuration overview](/build/docs/build-config) first.\n\nBefore you begin\n\n-\n\n\n Enable the Cloud Build, Firebase, and Resource Manager APIs.\n\n\n [Enable the APIs](https://console.cloud.google.com/flows/enableapi?apiid=cloudbuild.googleapis.com,firebase.googleapis.com,firebasehosting.googleapis.com,cloudresourcemanager.googleapis.com&redirect=https://cloud.google.com/build/docs/deploying-builds/deploy-firebase)\n\n\u003c!-- --\u003e\n\n- To run the `gcloud` commands on this page, install the\n [Google Cloud CLI](/sdk).\n\n- Keep your application source code including `firebase.json` handy. Your\n source code needs to be stored in a repository, such as\n Cloud Source Repositories, GitHub, or Bitbucket.\n\n- If you don't already have a project to deploy to Firebase, you can\n create a default project by\n [installing and initializing Firebase](https://firebase.google.com/docs/hosting/quickstart#initialize).\n\n| **Caution:** Effective June 17, 2024, Cloud Source Repositories isn't available\n| to new customers. If your organization hasn't\n| previously used Cloud Source Repositories, you can't enable the API or use\n| Cloud Source Repositories. New projects not connected to an organization can't enable the\n| Cloud Source Repositories API. Organizations that have used Cloud Source Repositories prior to\n| June 17, 2024 are not affected by this change.\n\nRequired IAM permissions\n\n1. Open the IAM page in the Google Cloud console:\n\n [Open the IAM page](https://console.cloud.google.com/iam-admin/iam)\n2. Select your project and click **Open**.\n\n3. In the permissions table, locate the email for the service account you are\n using for the build and click the pencil icon.\n\n4. Add the `Cloud Build Service Account`(`roles/cloudbuild.builds.builder`),\n `Firebase Admin` (`roles/firebase.admin`), and`API Keys Admin`\n (`roles/serviceusage.apiKeysAdmin`)\n roles to the service account.\n\n5. Click **Save**.\n\nUsing the `firebase` Docker image\n\nCloud Build provides a builder image that you can use to invoke\n`firebase` commands in Cloud Build. To use this builder in a\nCloud Build config file, you can use the `firebase` build step to\ndeploy to Firebase:\n\n1. Create a build config file named `cloudbuild.yaml` or\n `cloudbuild.json` where \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e is your\n Google Cloud project ID and \u003cvar translate=\"no\"\u003eFIREBASE_PROJECT_ID\u003c/var\u003e is\n your Firebase project ID:\n\n YAML \n\n steps:\n - name: \"us-docker.pkg.dev/firebase-cli/us/firebase\"\n args: ['deploy', '--project=\u003cvar translate=\"no\"\u003eFIREBASE_PROJECT_ID\u003c/var\u003e', '--only=hosting']\n ## Or, target a specific version of firebase-tools\n - name: \"us-docker.pkg.dev/firebase-cli/us/firebase\":\u003cvar translate=\"no\"\u003ex.y.z\u003c/var\u003e\n args: ['deploy', '--project=\u003cvar translate=\"no\"\u003eFIREBASE_PROJECT_ID\u003c/var\u003e', '--only=hosting']\n\n JSON \n\n {\n \"steps\": [\n {\n \"name\": \"us-docker.pkg.dev/firebase-cli/us/firebase\",\n \"args\": [\n \"deploy\",\n \"--project\",\n \"\u003cvar translate=\"no\"\u003eFIREBASE_PROJECT_ID\u003c/var\u003e\",\n \"--only\",\n \"hosting\"\n ]\n }\n ]\n }\n\n You can choose a specific version of `firebase-tools` by using \n\n `name: \"us-docker.pkg.dev/firebase-cli/us/firebase\":`\u003cvar translate=\"no\"\u003ex.y.z\u003c/var\u003e\n2. Start the build using the build config file:\n\n gcloud builds submit --region=\u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003eREGION\u003c/span\u003e\u003c/var\u003e --config \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003eCONFIG_FILE_PATH\u003c/span\u003e\u003c/var\u003e \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003eSOURCE_DIRECTORY\u003c/span\u003e\u003c/var\u003e\n\n Where:\n - \u003cvar translate=\"no\"\u003eREGION\u003c/var\u003e is one of the [supported build regions](/build/docs/locations).\n - \u003cvar translate=\"no\"\u003eCONFIG_FILE_PATH\u003c/var\u003e is the path to the build config file.\n - \u003cvar translate=\"no\"\u003eSOURCE_DIRECTORY\u003c/var\u003e is the path or URL to the source code.\n\nContinuous deployment\n\nYou can automate the deployment of your software to Firebase by\ncreating Cloud Build triggers. You can configure triggers to build\nand deploy images whenever you update your source code.\n\nTo automate your deployment to Firebase:\n\n1. In your repository, add a build config file with steps to invoke the\n `firebase deploy` command where \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e\n is your Google Cloud project ID:\n\n YAML \n\n steps:\n - name: us-docker.pkg.dev/firebase-cli/us/firebase\n args: ['deploy', '--project=\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e', '--only=hosting']\n\n JSON \n\n {\n \"steps\": [\n {\n \"name\": \"us-docker.pkg.dev/firebase-cli/us/firebase\",\n \"args\": [\n \"deploy\",\n \"--project\",\n \"\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e\",\n \"--only\",\n \"hosting\"\n ]\n }\n ]\n }\n\n2. Create a trigger with the build config file created in the previous step:\n\n 1. Open the **Triggers** page in the Google Cloud console:\n\n [Open Triggers page](https://console.cloud.google.com/cloud-build/triggers)\n 2. Select your project from the project selector drop-down menu at the top of\n the page.\n\n 3. Click **Open**.\n\n 4. Click **Create trigger**.\n\n On the **Create trigger** page, enter the following settings:\n 1. Enter a name for your trigger.\n\n 2. Select the repository event to start your trigger.\n\n 3. Select the repository that contains your source code and build\n config file.\n\n 4. Specify the regex for the branch or tag name that will start your\n trigger.\n\n 5. **Configuration**: Choose the build config file you created\n previously.\n\n 5. Click **Create** to save your build trigger.\n\nAnytime you push new code to your repository, you will automatically start a\nbuild and deploy on Firebase.\n\nFor more information on creating Cloud Build triggers, see\n[Creating and managing build triggers](/build/docs/automating-builds/create-manage-triggers).\n\nCode example\n\nTo view a code sample for deploying to Firebase using Cloud Build, go to\n[deploy-firebase-example](https://github.com/GoogleCloudPlatform/cloud-build-samples/tree/main/deploy-firebase-example).\n\nWhat's next\n\n- Learn how to [perform blue/green deployments on Compute Engine](/build/docs/deploying-builds/deploy-compute-engine)\n- Learn how to [deploy on Cloud Run](/build/docs/deploying-builds/deploy-cloud-run)\n- Learn how to [deploy on GKE](/build/docs/deploying-builds/deploy-gke)\n- Learn how to [deploy on Cloud Run functions](/build/docs/deploying-builds/deploy-functions)\n- Learn how to [deploy on App Engine](/build/docs/deploying-builds/deploy-appengine)\n- Learn how to [troubleshoot build errors](/build/docs/troubleshooting)"]]