How to deploy an app to Firebase Hosting using codemagic.yaml
Codemagic allows you to deploy your web application to Firebase Hosting.
With Codemagic, publishing to Firebase Hosting is a straightforward process as the Firebase CLI is already pre-installed on our virtual machines. Please note that you will have to set it up for your project locally before publishing it to Firebase Hosting. You can find more information in the official documentation for Firebase.
- To get started with adding Firebase Hosting to Codemagic, you will need to obtain your Firebase token. In order to do that, run
firebase login:ciin your local terminal.
- After running the command, your default browser should prompt for authorization to your Firebase project - when access is granted, the necessary token will appear in your terminal.
- Copy and encrypt the token using the Codemagic UI.
- Add your encrypted token to your .yaml file by setting it under your environment variables with the name
- Create a new script for publishing to Firebase Hosting in your scripts section of the .yaml file and add it right after the build step
- name: Publish to Firebase Hosting script: | firebase deploy --token "$FIREBASE_TOKEN"
When the build is successful, you can see your application published to Firebase Hosting. You can find the direct URL to the deployed build also from the log output in Codemagic UI:
✔ Deploy complete! Project Console: https://console.firebase.google.com/project/your-project/overview Hosting URL: https://your-project.web.app