Deploy to Firebase Stay organized with collections Save and categorize content based on your preferences.
This page explains how to deploy applications toFirebase usingCloud Build. If you're new to Cloud Build, read thequickstarts and theBuild configuration overview first.
Before you begin
Enable the Cloud Build, Firebase, and Resource Manager APIs.
Roles required to enable APIs
To enable APIs, you need the Service Usage Admin IAM role (
roles/serviceusage.serviceUsageAdmin), which contains theserviceusage.services.enablepermission.Learn how to grant roles.
To run the
gcloudcommands on this page, install theGoogle Cloud CLI.Keep your application source code including
firebase.jsonhandy. Yoursource code needs to be stored in a repository, such asCloud Source Repositories, GitHub, or Bitbucket.If you don't already have a project to deploy to Firebase, you cancreate a default project byinstalling and initializing Firebase.
Caution: Effective June 17, 2024, Cloud Source Repositories isn't available to new customers. If your organization hasn't previously used Cloud Source Repositories, you can't enable the API or use Cloud Source Repositories. New projects not connected to an organization can't enable the Cloud Source Repositories API. Organizations that have used Cloud Source Repositories prior to June 17, 2024 are not affected by this change.
Required IAM permissions
In the Google Cloud console, go to thesettings Cloud BuildPermissions page:
Select the service account for your build.
Set the status of the following roles toEnabled:
- Cloud Build Service Account | Allows the legacy Cloud Buildservice account to update builds, write build logs, and store buildartifacts.
- Firebase Admin | Allows Cloud Build to access Firebase.
- API Keys Viewer | Allows Cloud Build to access the currentFirebase Hosting configuration during build deployment.
Using thefirebase Docker image
Cloud Build provides a builder image that you can use to invokefirebase commands in Cloud Build. To use this builder in aCloud Build config file, you can use thefirebase build step todeploy to Firebase:
Create a build config file named
cloudbuild.yamlorcloudbuild.jsonwherePROJECT_ID is yourGoogle Cloud project ID andFIREBASE_PROJECT_ID isyour 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']JSON
{"steps":[{"name":"us-docker.pkg.dev/firebase-cli/us/firebase","args":["deploy","--project","FIREBASE_PROJECT_ID","--only","hosting"]}]}You can choose a specific version of
firebase-toolsby usingname: "us-docker.pkg.dev/firebase-cli/us/firebase":x.y.zStart the build using the build config file:
gcloudbuildssubmit--region=REGION--configCONFIG_FILE_PATHSOURCE_DIRECTORYWhere:
- REGION is one of thesupported build regions.
- 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 bycreating Cloud Build triggers. You can configure triggers to buildand 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 deploycommand wherePROJECT_IDis your Google Cloud project ID:YAML
steps:-name:us-docker.pkg.dev/firebase-cli/us/firebaseargs:['deploy','--project=PROJECT_ID','--only=hosting']JSON
{"steps":[{"name":"us-docker.pkg.dev/firebase-cli/us/firebase","args":["deploy","--project","PROJECT_ID","--only","hosting"]}]}Create a trigger with the build config file created in the previous step:
Open theTriggers page in the Google Cloud console:
Select your project from the project selector drop-down menu at the top ofthe page.
ClickOpen.
ClickCreate trigger.
On theCreate trigger page, enter the following settings:
Enter a name for your trigger.
Select the repository event to start your trigger.
Select the repository that contains your source code and buildconfig file.
Specify the regex for the branch or tag name that will start yourtrigger.
Configuration: Choose the build config file you createdpreviously.
ClickCreate to save your build trigger.
Anytime you push new code to your repository, you will automatically start abuild and deploy on Firebase.
For more information on creating Cloud Build triggers, seeCreating and managing build triggers.
Code example
To view a code sample for deploying to Firebase using Cloud Build, go todeploy-firebase-example.
What's next
- Learn how toperform blue/green deployments on Compute Engine
- Learn how todeploy on Cloud Run
- Learn how todeploy on GKE
- Learn how todeploy on Cloud Run functions
- Learn how todeploy on App Engine
- Learn how totroubleshoot build errors
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2026-02-18 UTC.