From fb24cc1cc2279d03b048510a9e612f191a7d4644 Mon Sep 17 00:00:00 2001 From: Alberto Di Gioacchino Date: Thu, 18 Feb 2021 16:53:13 +0100 Subject: [PATCH] feat(all-general): add env variable --- .github/workflows/build-and-deploy-on-merge.yml | 1 + .github/workflows/build-and-deploy-on-version.yml | 2 ++ .github/workflows/build-and-test-on-pr.yml | 1 + packages/game-app/.env.template | 2 +- packages/game-app/src/_shared/auth/saga.ts | 4 ++-- packages/game-app/src/_shared/config/config.ts | 1 + 6 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-and-deploy-on-merge.yml b/.github/workflows/build-and-deploy-on-merge.yml index 6ce84870..733c570d 100644 --- a/.github/workflows/build-and-deploy-on-merge.yml +++ b/.github/workflows/build-and-deploy-on-merge.yml @@ -33,6 +33,7 @@ jobs: REACT_APP_FIREBASE_CONFIG_STORAGE_BUCKET: ${{ secrets.REACT_APP_FIREBASE_CONFIG_STORAGE_BUCKET }} REACT_APP_FIREBASE_CONFIG_MESSAGING_SENDER_ID: ${{ secrets.REACT_APP_FIREBASE_CONFIG_MESSAGING_SENDER_ID }} REACT_APP_FIREBASE_CONFIG_APP_ID: ${{ secrets.REACT_APP_FIREBASE_CONFIG_APP_ID }} + REACT_APP_ENV: dev - name: Setup database target run: npm run scripts:deploy-database-instances-rules diff --git a/.github/workflows/build-and-deploy-on-version.yml b/.github/workflows/build-and-deploy-on-version.yml index 6d8005a8..c0c5a8da 100644 --- a/.github/workflows/build-and-deploy-on-version.yml +++ b/.github/workflows/build-and-deploy-on-version.yml @@ -32,6 +32,7 @@ jobs: REACT_APP_FIREBASE_CONFIG_STORAGE_BUCKET: ${{ secrets.REACT_APP_FIREBASE_CONFIG_STORAGE_BUCKET }} REACT_APP_FIREBASE_CONFIG_MESSAGING_SENDER_ID: ${{ secrets.REACT_APP_FIREBASE_CONFIG_MESSAGING_SENDER_ID }} REACT_APP_FIREBASE_CONFIG_APP_ID: ${{ secrets.REACT_APP_FIREBASE_CONFIG_APP_ID }} + REACT_APP_ENV: test - name: Setup database target run: npm run scripts:deploy-database-instances-rules @@ -73,6 +74,7 @@ jobs: REACT_APP_FIREBASE_CONFIG_STORAGE_BUCKET: ${{ secrets.REACT_APP_FIREBASE_CONFIG_STORAGE_BUCKET }} REACT_APP_FIREBASE_CONFIG_MESSAGING_SENDER_ID: ${{ secrets.REACT_APP_FIREBASE_CONFIG_MESSAGING_SENDER_ID }} REACT_APP_FIREBASE_CONFIG_APP_ID: ${{ secrets.REACT_APP_FIREBASE_CONFIG_APP_ID }} + REACT_APP_ENV: prod - name: Setup database target run: npm run scripts:deploy-database-instances-rules diff --git a/.github/workflows/build-and-test-on-pr.yml b/.github/workflows/build-and-test-on-pr.yml index 63126f0e..9c297d83 100644 --- a/.github/workflows/build-and-test-on-pr.yml +++ b/.github/workflows/build-and-test-on-pr.yml @@ -33,6 +33,7 @@ jobs: REACT_APP_FIREBASE_CONFIG_MESSAGING_SENDER_ID: ${{ secrets.REACT_APP_FIREBASE_CONFIG_MESSAGING_SENDER_ID }} REACT_APP_FIREBASE_CONFIG_APP_ID: ${{ secrets.REACT_APP_FIREBASE_CONFIG_APP_ID }} REACT_APP_FIREBASE_USE_EMULATORS: true + REACT_APP_ENV: dev - name: Lint functions run: npm --prefix packages/functions run lint diff --git a/packages/game-app/.env.template b/packages/game-app/.env.template index 3022316c..48d36e4d 100644 --- a/packages/game-app/.env.template +++ b/packages/game-app/.env.template @@ -6,6 +6,6 @@ REACT_APP_FIREBASE_CONFIG_STORAGE_BUCKET= REACT_APP_FIREBASE_CONFIG_MESSAGING_SENDER_ID= REACT_APP_FIREBASE_CONFIG_APP_ID= REACT_APP_FIREBASE_USE_EMULATORS= +REACT_APP_ENV= FIREBASE_AUTH_EMULATOR_HOST= FIRESTORE_EMULATOR_HOST= -REACT_APP_FUNCTIONS_BASE_URL= diff --git a/packages/game-app/src/_shared/auth/saga.ts b/packages/game-app/src/_shared/auth/saga.ts index c96bef42..c8ef14a3 100644 --- a/packages/game-app/src/_shared/auth/saga.ts +++ b/packages/game-app/src/_shared/auth/saga.ts @@ -4,6 +4,7 @@ import firebase from 'firebase/app'; import 'firebase/auth'; import { addRequestStatusManagement } from '@pipeline/requests-status'; import { RoutingPath } from '@pipeline/routing'; +import CONFIG from '@pipeline/app-config'; function getCurrentUser(): Promise { return new Promise(resolve => { @@ -23,8 +24,7 @@ function getCurrentUser(): Promise { function* initializeAuthSaga() { const user: AuthUser | null = yield call(getCurrentUser); - // todo do it only in dev and uat - if (user) { + if (user && (CONFIG.REACT_APP_ENV === 'dev' || CONFIG.REACT_APP_ENV === 'test')) { yield call(() => firebase.auth().currentUser?.getIdToken(true)); } yield put(actions.setLoggedUser(user)); diff --git a/packages/game-app/src/_shared/config/config.ts b/packages/game-app/src/_shared/config/config.ts index 8ff61cc8..d13432c8 100644 --- a/packages/game-app/src/_shared/config/config.ts +++ b/packages/game-app/src/_shared/config/config.ts @@ -7,4 +7,5 @@ export interface Config { REACT_APP_FIREBASE_CONFIG_MESSAGING_SENDER_ID: string; REACT_APP_FIREBASE_CONFIG_APP_ID: string; REACT_APP_FIREBASE_USE_EMULATORS: string; + REACT_APP_ENV: 'dev' | 'test' | 'prod'; }