Skip to content

Commit fd99bd4

Browse files
authored
Merge pull request #2235 from IDEMSInternational/feat/deployment-firebase
feat: deployment-based firebase config
2 parents 6f3cc05 + eabc2da commit fd99bd4

27 files changed

+235
-336
lines changed

.firebaserc

-45
This file was deleted.

.github/workflows/reusable-app-build.yml

-4
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,6 @@ jobs:
8080
if: env.DEPLOYMENT_PRIVATE_KEY != ''
8181
run: echo "${{env.DEPLOYMENT_PRIVATE_KEY}}" > ./.idems_app/deployments/${{env.DEPLOYMENT_NAME}}/encrypted/private.key
8282

83-
- name: Populate Firebase Config
84-
if: env.FIREBASE_CONFIG != ''
85-
run: echo 'export const firebaseConfig = ${{env.FIREBASE_CONFIG}}' > src/environments/firebaseConfig.ts
86-
8783
- name: Setup Node
8884
uses: actions/setup-node@v3
8985
with:

.github/workflows/reusable-content-sync.yml

-4
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,6 @@ jobs:
7272
if: env.DEPLOYMENT_PRIVATE_KEY != ''
7373
run: echo "${{env.DEPLOYMENT_PRIVATE_KEY}}" > ./.idems_app/deployments/${{env.DEPLOYMENT_NAME}}/encrypted/private.key
7474

75-
# TODO - populate firebase as part of deployment set
76-
- name: Populate Firebase Config
77-
if: env.FIREBASE_CONFIG != ''
78-
run: echo 'export const firebaseConfig = ${{env.FIREBASE_CONFIG}}' > src/environments/firebaseConfig.ts
7975
- name: Setup Node
8076
uses: actions/setup-node@v3
8177
with:

.github/workflows/test-app-build.yml

-4
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,6 @@ jobs:
8181
if: env.DEPLOYMENT_PRIVATE_KEY != ''
8282
run: echo "${{env.DEPLOYMENT_PRIVATE_KEY}}" > ./.idems_app/deployments/${{env.DEPLOYMENT_NAME}}/encrypted/private.key
8383

84-
- name: Populate Firebase Config
85-
if: env.FIREBASE_CONFIG != ''
86-
run: echo 'export const firebaseConfig = ${{env.FIREBASE_CONFIG}}' > src/environments/firebaseConfig.ts
87-
8884
- name: Setup Node
8985
uses: actions/setup-node@v3
9086
with:

.github/workflows/web-build.yml

-5
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,6 @@ jobs:
156156
# Exact population varies depending on whether is PR, release, dispatch etc.
157157
#############################################################################
158158

159-
# TODO - populate firebase as part of deployment set
160-
- name: Populate firebaseConfig.ts
161-
if: ${{env.FIREBASE_CONFIG_TS}}
162-
run: echo $FIREBASE_CONFIG_TS > src/environments/firebaseConfig.ts
163-
164159
- name: Populate git sha
165160
if: ${{env.GIT_SHA}}
166161
run: echo "export const GIT_SHA = \"$GIT_SHA\";" > src/environments/sha.ts

.gitignore

+7-2
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ google-services.json
3535
resources/android
3636
resources/ios
3737
package-lock.json
38-
src/environments/firebaseConfig.ts
3938
src/assets/app_data
4039
**/*.jks
41-
.firebase
40+
41+
4242

4343
/scripts/input
4444
/scripts/output
@@ -73,6 +73,11 @@ yarn.auto-install
7373
# Generated by https://supabase.com/docs/reference/cli/supabase-init
7474
supabase
7575

76+
# Firebase
77+
firebase.json
78+
.firebase
79+
.firebaserc
80+
7681
# Avoid comitting private keys
7782
private.key
7883

.template.firebaserc

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"projects": {
3+
"default": "${FIREBASE_PROJECT_ID}"
4+
},
5+
"targets": {
6+
"${FIREBASE_PROJECT_ID}": {
7+
"hosting": {
8+
"${FIREBASE_HOSTING_TARGET}": [
9+
"${FIREBASE_PROJECT_ID}"
10+
]
11+
}
12+
}
13+
},
14+
"etags": {}
15+
}

README.md

-10
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,6 @@ This will present an interactive list of deployments to select from.
4747

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

50-
### Firebase
51-
To be able to run the full project a specific configuration file needs to be included to access
52-
the online database and authentication methods.
53-
```
54-
$ cp src/environments/firebaseConfig.sample.ts src/environments/firebaseConfig.ts
55-
```
56-
The default file is blank. It should be replaced with a version requested from the dev team.
57-
58-
(Note - this process will likely be simplified in the future)
59-
6050
## Running locally
6151

6252
### Start the local server

documentation/docs/developers/web-previews.md

+23
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,28 @@
11
# Web Previews
2+
Web previews can be configured for a deployment using the [reusable-deploy-web-preview](../../../.github\workflows\reusable-deploy-web-preview.yml) github action.
23

4+
The action requires a Firebase project to be setup, and environment variables set to specify the `FIREBASE_PROJECT_ID` and `FIREBASE_DEPLOYMENT_TARGET`
5+
6+
This action should be called from a child content repo and configured as required. E.g.
7+
8+
_.github/workflows/deploy-firebase.yml_
9+
```yml
10+
name: Deploy - Firebase
11+
12+
on:
13+
push:
14+
branches:
15+
- "main"
16+
17+
jobs:
18+
web_preview:
19+
uses: IDEMSInternational/parenting-app-ui/.github/workflows/reusable-deploy-web-preview.yml@master
20+
secrets: inherit
21+
```
22+
23+
24+
---
25+
# Legacy Docs
326
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.
427

528
## Updating an existing web preview

documentation/docs/index.md

-11
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,6 @@ You will be prompted to specify the deployment type, this should be a `New Local
4141

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

44-
### Firebase
45-
To be able to run the full project a specific configuration file needs to be included to access
46-
the online database and authentication methods.
47-
```
48-
$ cp src/environments/firebaseConfig.sample.ts src/environments/firebaseConfig.ts
49-
```
50-
The default file is blank and so some features may not be available (e.g. testing google sign-in)
51-
It can be replaced with a version requested from the dev team.
52-
53-
(Note - this process will likely be simplified in the future)
54-
5544
## Running locally
5645

5746
### Start the local server

firebase.json

-125
This file was deleted.

firebase.template.json

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"hosting": [
3+
{
4+
"target": "${FIREBASE_HOSTING_TARGET}",
5+
"public": "www",
6+
"ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
7+
"rewrites": [
8+
{
9+
"source": "**",
10+
"destination": "/index.html"
11+
}
12+
]
13+
}
14+
]
15+
}

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
"@angular/common": "~17.2.2",
3737
"@angular/core": "~17.2.2",
3838
"@angular/elements": "^17.2.2",
39-
"@angular/fire": "17.0.1",
4039
"@angular/forms": "~17.2.2",
4140
"@angular/platform-browser": "~17.2.2",
4241
"@angular/platform-browser-dynamic": "~17.2.2",

packages/data-models/deployment.model.ts

+30-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { IGdriveEntry } from "../@idemsInternational/gdrive-tools";
22
import type { IAppConfig } from "./appConfig";
33

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

77
export interface IDeploymentConfig {
88
/** Friendly name used to identify the deployment name */
@@ -60,6 +60,30 @@ export interface IDeploymentConfig {
6060
/** filter function that receives basic file info such as relativePath and size. Default `(fileEntry)=>true`*/
6161
assets_filter_function: (fileEntry: IContentsEntry) => boolean;
6262
};
63+
/**
64+
* Specify if using firebase for auth and crashlytics.
65+
* Requires firebase config available through encrypted config */
66+
firebase: {
67+
/** Project config as specified in firebase console (recommend loading from encrypted environment) */
68+
config?: {
69+
apiKey: string;
70+
authDomain: string;
71+
databaseURL: string;
72+
projectId: string;
73+
storageBucket: string;
74+
messagingSenderId: string;
75+
appId: string;
76+
measurementId: string;
77+
};
78+
auth: {
79+
/** Enables `auth` actions to allow user sign-in/out */
80+
enabled: boolean;
81+
};
82+
crashlytics: {
83+
/** Enables app crash reports to firebase crashlytics */
84+
enabled: boolean;
85+
};
86+
};
6387
git: {
6488
/** Url of external git repo to store content */
6589
content_repo?: string;
@@ -136,6 +160,11 @@ export const DEPLOYMENT_CONFIG_EXAMPLE_DEFAULTS: IDeploymentConfig = {
136160
sheets_filter_function: (flow) => true,
137161
assets_filter_function: (fileEntry) => true,
138162
},
163+
firebase: {
164+
config: null,
165+
auth: { enabled: false },
166+
crashlytics: { enabled: true },
167+
},
139168
supabase: {
140169
enabled: false,
141170
},

0 commit comments

Comments
 (0)