Skip to content

Commit

Permalink
feat(all-general): add env variable
Browse files Browse the repository at this point in the history
  • Loading branch information
albertodigioacchino committed Feb 18, 2021
1 parent 2dc112a commit fb24cc1
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build-and-deploy-on-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/build-and-deploy-on-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/build-and-test-on-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/game-app/.env.template
Original file line number Diff line number Diff line change
Expand Up @@ -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=
4 changes: 2 additions & 2 deletions packages/game-app/src/_shared/auth/saga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<AuthUser | null> {
return new Promise<AuthUser | null>(resolve => {
Expand All @@ -23,8 +24,7 @@ function getCurrentUser(): Promise<AuthUser | null> {

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));
Expand Down
1 change: 1 addition & 0 deletions packages/game-app/src/_shared/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}

0 comments on commit fb24cc1

Please sign in to comment.