Firebase
Firebase Hosting is a GCP service that allows you to host static websites and single-page apps. Firebase Hosting can deploy Evidence apps by linking to a Git repository.
Prerequisites
- A GCP account
- An Evidence project pushed to Git service like GitHub, GitLab, or Bitbucket.
Deploy Evidence to Firebase
Firebase CLI
The Firebase CLI is somewhat buggy, so you sometimes need to try the commands multiple times for them to succeed.
- From the Firebase console, click Create a project.
- Enter a project name, accept the terms of service, and click Continue.
- Choose whether to enable Google Analytics (not required), and click Create project.
- In the terminal, install the Firebase CLI:
npm install -g firebase-tools
- Log in to Firebase, and authenticate via the browser:
firebase login
- Initialize Firebase Hosting in your project:
firebase init hosting
- Select
Use an existing project
- Select a default Firebase project for this directory: Select project you created
- What do you want to use as your public directory?
build
- Configure as a single-page app (rewrite all URLs to /index.html)?
No
- (If asked) File build/index.html already exists. Overwrite?
No
- Set up automatic builds and deploys with GitHub?
Yes
- Select a GitHub repository to connect to this project: Type your repo name
- Set up the workflow to run a build script before every deploy?
Yes
- What script should be run before every deploy?
npm ci && npm run sources && npm run build
- Set up automatic deployment to your site's live channel when a PR is merged?
Yes
- What is the name of the GitHub branch associated with your site's live channel?
main
- Select
- Add secrets to your GitHub repo: Settings > Secrets and variables > Actions
- With your Evidence dev server running, go to the settings page and copy each of the environment variables
- Alternatively, you can find credentials in
connection.options.yaml
files in your/sources/your_source
directory. The key format used should beEVIDENCE_SOURCE__[your_source]__[option_name]
(Note the casing matches your source names, and the double underscores). Note that the values are base64 encoded, and will need to be decoded. - Add each of them as secrets to your GitHub repo
- Build your app locally (if you haven't already):
npm i && npm run sources && npm run build
- Deploy your app for the first time
firebase deploy --only hosting
- Edit
firebase-hosting-merge.yml
andfirebase-hosting-pull-request.yml
to add your environment variables as GitHub secrets (note that GitHub capitalizes the names of secrets)- run: npm ci && npm run sources && npm run build env: EVIDENCE_SOURCE__my_source__username: ${{ secrets.EVIDENCE_SOURCE__MY_SOURCE__USERNAME }} EVIDENCE_SOURCE__my_source__private_key: ${{ secrets.EVIDENCE_SOURCE__MY_SOURCE__PRIVATE_KEY }}
- Commit and push these newly created files:
firebase.json
,.firebaserc
,firebase-hosting-merge.yml
,firebase-hosting-pull-request.yml
. - Update your GitHub workflow settings to allow Workflows to Read and write permissions. This is required for the Pull Request preview GitHub Action to work. [your repo] > Settings > Actions > General > Workflow permissions
Your app should now be live on Firebase Hosting at https://<project-id>.web.app
.
Domains, Authentication and Scheduling
Evidence Cloud
Deploying on Evidence Cloud comes with:
- User authentication with email-password or SSO via Google Workspace, Microsoft Entra, Okta etc.
- Your own Evidence subdomain, https://[my-subdomain].evidence.app, or custom domain.
- Scheduled builds to refresh your data at specific intervals, e.g., daily, hourly.
Authentication
Firebase Authentication is not a suitable authentication for static apps on Firebase Hosting.
Custom domains
You can set up a custom domain on Firebase Hosting.
Firebase dashboard > [your project] > Hosting (in the left sidebar) > Domains > Add custom domain
Data refresh
To adjust your deployment schedule, modify the workflow file in your repository, adding a schedule
trigger.
on:
schedule:
- cron: '0 0 * * *' # This is midnight every day