To run the gcloud commands on this page, install the
Google Cloud CLI.
Keep your application source code including firebase.json handy. Your
source code needs to be stored in a repository, such as
Cloud Source Repositories, GitHub, or Bitbucket.
In the permissions table, locate the email for the service account you are
using for the build and click the pencil icon.
Add the Cloud Build Service Account(roles/cloudbuild.builds.builder),
Firebase Admin (roles/firebase.admin), andAPI Keys Admin
(roles/serviceusage.apiKeysAdmin)
roles to the service account.
Click Save.
Using the firebase Docker image
Cloud Build provides a builder image that you can use to invoke
firebase commands in Cloud Build. To use this builder in a
Cloud Build config file, you can use the firebase build step to
deploy to Firebase:
Create a build config file named cloudbuild.yaml or
cloudbuild.json where PROJECT_ID is your
Google Cloud project ID and FIREBASE_PROJECT_ID is
your Firebase project ID:
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 is the path to the build config file.
SOURCE_DIRECTORY is the path or URL to the source code.
Continuous deployment
You can automate the deployment of your software to Firebase by
creating Cloud Build triggers. You can configure triggers to build
and deploy images whenever you update your source code.
To automate your deployment to Firebase:
In your repository, add a build config file with steps to invoke the
firebase deploy command where PROJECT_ID
is your Google Cloud project ID:
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 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,["# Deploying to Firebase\n\nThis 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\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\n### Required 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---------------------------------\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---------------------\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------------\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\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)"]]