From 5a4f321b86cc64adb837152567f77784c7c4fa97 Mon Sep 17 00:00:00 2001 From: yevkim Date: Wed, 27 Nov 2024 21:28:48 +0800 Subject: [PATCH] Fix deploy functions 13 --- .github/workflows/deploy_functions.yml | 8 +++----- backend/functions/fb_manager/firebaseManager.py | 4 ++++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/deploy_functions.yml b/.github/workflows/deploy_functions.yml index 6dc42b4..175fd15 100644 --- a/.github/workflows/deploy_functions.yml +++ b/.github/workflows/deploy_functions.yml @@ -41,8 +41,6 @@ jobs: # Step 6: deploy functions - name: Deploy functions working-directory: backend - run: | - export GOOGLE_APPLICATION_CREDENTIALS=$HOME/gcloud.json - echo "GOOGLE_APPLICATION_CREDENTIALS=$GOOGLE_APPLICATION_CREDENTIALS" - cat $GOOGLE_APPLICATION_CREDENTIALS - npx firebase-tools deploy --only functions --debug --token "${{ secrets.FIREBASE_TOKEN_SCHEMESSG_V3_DEV }}" + env: + GOOGLE_APPLICATION_CREDENTIALS: $HOME/gcloud.json + run: npx firebase-tools deploy --only functions --debug --token "${{ secrets.FIREBASE_TOKEN_SCHEMESSG_V3_DEV }}" diff --git a/backend/functions/fb_manager/firebaseManager.py b/backend/functions/fb_manager/firebaseManager.py index 4a9e84b..63ea4ab 100644 --- a/backend/functions/fb_manager/firebaseManager.py +++ b/backend/functions/fb_manager/firebaseManager.py @@ -30,6 +30,10 @@ def _initialize_app(self): # Replace newlines in private key # private_key = os.getenv("FB_PRIVATE_KEY").replace("\\n", "\n") path_to_creds = os.getenv("GOOGLE_APPLICATION_CREDENTIALS") + + if not path_to_creds or not os.path.exists(path_to_creds): + raise ValueError(f"Invalid certificate path: {path_to_creds}. Make sure GOOGLE_APPLICATION_CREDENTIALS is set properly.") + cred = credentials.Certificate(path_to_creds) # Adjust path as needed # cred = credentials.Certificate(