Skip to content

Commit

Permalink
Merge pull request #2235 from IDEMSInternational/feat/deployment-fire…
Browse files Browse the repository at this point in the history
…base

feat: deployment-based firebase config
  • Loading branch information
jfmcquade authored Apr 2, 2024
2 parents 6f3cc05 + eabc2da commit fd99bd4
Show file tree
Hide file tree
Showing 27 changed files with 235 additions and 336 deletions.
45 changes: 0 additions & 45 deletions .firebaserc

This file was deleted.

4 changes: 0 additions & 4 deletions .github/workflows/reusable-app-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,6 @@ jobs:
if: env.DEPLOYMENT_PRIVATE_KEY != ''
run: echo "${{env.DEPLOYMENT_PRIVATE_KEY}}" > ./.idems_app/deployments/${{env.DEPLOYMENT_NAME}}/encrypted/private.key

- name: Populate Firebase Config
if: env.FIREBASE_CONFIG != ''
run: echo 'export const firebaseConfig = ${{env.FIREBASE_CONFIG}}' > src/environments/firebaseConfig.ts

- name: Setup Node
uses: actions/setup-node@v3
with:
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/reusable-content-sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,6 @@ jobs:
if: env.DEPLOYMENT_PRIVATE_KEY != ''
run: echo "${{env.DEPLOYMENT_PRIVATE_KEY}}" > ./.idems_app/deployments/${{env.DEPLOYMENT_NAME}}/encrypted/private.key

# TODO - populate firebase as part of deployment set
- name: Populate Firebase Config
if: env.FIREBASE_CONFIG != ''
run: echo 'export const firebaseConfig = ${{env.FIREBASE_CONFIG}}' > src/environments/firebaseConfig.ts
- name: Setup Node
uses: actions/setup-node@v3
with:
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/test-app-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,6 @@ jobs:
if: env.DEPLOYMENT_PRIVATE_KEY != ''
run: echo "${{env.DEPLOYMENT_PRIVATE_KEY}}" > ./.idems_app/deployments/${{env.DEPLOYMENT_NAME}}/encrypted/private.key

- name: Populate Firebase Config
if: env.FIREBASE_CONFIG != ''
run: echo 'export const firebaseConfig = ${{env.FIREBASE_CONFIG}}' > src/environments/firebaseConfig.ts

- name: Setup Node
uses: actions/setup-node@v3
with:
Expand Down
5 changes: 0 additions & 5 deletions .github/workflows/web-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,6 @@ jobs:
# Exact population varies depending on whether is PR, release, dispatch etc.
#############################################################################

# TODO - populate firebase as part of deployment set
- name: Populate firebaseConfig.ts
if: ${{env.FIREBASE_CONFIG_TS}}
run: echo $FIREBASE_CONFIG_TS > src/environments/firebaseConfig.ts

- name: Populate git sha
if: ${{env.GIT_SHA}}
run: echo "export const GIT_SHA = \"$GIT_SHA\";" > src/environments/sha.ts
Expand Down
9 changes: 7 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ google-services.json
resources/android
resources/ios
package-lock.json
src/environments/firebaseConfig.ts
src/assets/app_data
**/*.jks
.firebase



/scripts/input
/scripts/output
Expand Down Expand Up @@ -73,6 +73,11 @@ yarn.auto-install
# Generated by https://supabase.com/docs/reference/cli/supabase-init
supabase

# Firebase
firebase.json
.firebase
.firebaserc

# Avoid comitting private keys
private.key

Expand Down
15 changes: 15 additions & 0 deletions .template.firebaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"projects": {
"default": "${FIREBASE_PROJECT_ID}"
},
"targets": {
"${FIREBASE_PROJECT_ID}": {
"hosting": {
"${FIREBASE_HOSTING_TARGET}": [
"${FIREBASE_PROJECT_ID}"
]
}
}
},
"etags": {}
}
10 changes: 0 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,6 @@ This will present an interactive list of deployments to select from.

See [Deployment Documentation](https://idemsinternational.github.io/parenting-app-ui/developers/deployments/) for information about creating and configuring deployments.

### Firebase
To be able to run the full project a specific configuration file needs to be included to access
the online database and authentication methods.
```
$ cp src/environments/firebaseConfig.sample.ts src/environments/firebaseConfig.ts
```
The default file is blank. It should be replaced with a version requested from the dev team.

(Note - this process will likely be simplified in the future)

## Running locally

### Start the local server
Expand Down
23 changes: 23 additions & 0 deletions documentation/docs/developers/web-previews.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
# Web Previews
Web previews can be configured for a deployment using the [reusable-deploy-web-preview](../../../.github\workflows\reusable-deploy-web-preview.yml) github action.

The action requires a Firebase project to be setup, and environment variables set to specify the `FIREBASE_PROJECT_ID` and `FIREBASE_DEPLOYMENT_TARGET`

This action should be called from a child content repo and configured as required. E.g.

_.github/workflows/deploy-firebase.yml_
```yml
name: Deploy - Firebase

on:
push:
branches:
- "main"

jobs:
web_preview:
uses: IDEMSInternational/parenting-app-ui/.github/workflows/reusable-deploy-web-preview.yml@master
secrets: inherit
```
---
# Legacy Docs
A preview for a given app deployment, running in browser, can be generated via GitHub. The URL for this preview can then be shared. In general, these previews are accessible at `<deployment_name>.web.app`, e.g. [wash.web.app](https://wash.web.app/). When viewing a web preview, it is recommended to [enable device mode] in Chrome DevTools in order to simulate the mobile experience.

## Updating an existing web preview
Expand Down
11 changes: 0 additions & 11 deletions documentation/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,6 @@ You will be prompted to specify the deployment type, this should be a `New Local

See [Deployment Documentation](./developers/deployments.md) for more information about configuring deployments

### Firebase
To be able to run the full project a specific configuration file needs to be included to access
the online database and authentication methods.
```
$ cp src/environments/firebaseConfig.sample.ts src/environments/firebaseConfig.ts
```
The default file is blank and so some features may not be available (e.g. testing google sign-in)
It can be replaced with a version requested from the dev team.

(Note - this process will likely be simplified in the future)

## Running locally

### Start the local server
Expand Down
125 changes: 0 additions & 125 deletions firebase.json

This file was deleted.

15 changes: 15 additions & 0 deletions firebase.template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"hosting": [
{
"target": "${FIREBASE_HOSTING_TARGET}",
"public": "www",
"ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
]
}
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
"@angular/common": "~17.2.2",
"@angular/core": "~17.2.2",
"@angular/elements": "^17.2.2",
"@angular/fire": "17.0.1",
"@angular/forms": "~17.2.2",
"@angular/platform-browser": "~17.2.2",
"@angular/platform-browser-dynamic": "~17.2.2",
Expand Down
31 changes: 30 additions & 1 deletion packages/data-models/deployment.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { IGdriveEntry } from "../@idemsInternational/gdrive-tools";
import type { IAppConfig } from "./appConfig";

/** Update version to force recompile next time deployment set (e.g. after default config update) */
export const DEPLOYMENT_CONFIG_VERSION = 20230930;
export const DEPLOYMENT_CONFIG_VERSION = 20240314.0;

export interface IDeploymentConfig {
/** Friendly name used to identify the deployment name */
Expand Down Expand Up @@ -60,6 +60,30 @@ export interface IDeploymentConfig {
/** filter function that receives basic file info such as relativePath and size. Default `(fileEntry)=>true`*/
assets_filter_function: (fileEntry: IContentsEntry) => boolean;
};
/**
* Specify if using firebase for auth and crashlytics.
* Requires firebase config available through encrypted config */
firebase: {
/** Project config as specified in firebase console (recommend loading from encrypted environment) */
config?: {
apiKey: string;
authDomain: string;
databaseURL: string;
projectId: string;
storageBucket: string;
messagingSenderId: string;
appId: string;
measurementId: string;
};
auth: {
/** Enables `auth` actions to allow user sign-in/out */
enabled: boolean;
};
crashlytics: {
/** Enables app crash reports to firebase crashlytics */
enabled: boolean;
};
};
git: {
/** Url of external git repo to store content */
content_repo?: string;
Expand Down Expand Up @@ -136,6 +160,11 @@ export const DEPLOYMENT_CONFIG_EXAMPLE_DEFAULTS: IDeploymentConfig = {
sheets_filter_function: (flow) => true,
assets_filter_function: (fileEntry) => true,
},
firebase: {
config: null,
auth: { enabled: false },
crashlytics: { enabled: true },
},
supabase: {
enabled: false,
},
Expand Down
Loading

0 comments on commit fd99bd4

Please sign in to comment.