I have a functions folder at the root of my project with python functions (everything is working with emulator). In my local I follow these steps:
The above works when logged out of Firebase. If logged into firebase, I skip setting up the GOOGLE_APPLICATION_CREDENTIALS env variable and everything works fine. I've tested both scenarios multiple times (and it in different terminals) and am able to deploy my cloud functions fine.
However, I do exactly the same steps in my GitHub actions and run into an error. Both my Node (19.7.0) and Python (3.11) versions are the same between my local and GitHub actions. I had also tried with Node 18 to no effect. Here is my GitHub Actions config:
Just a note, Deploy Firestore Rules works fine by itself so I know the credentials are valid in the pipeline too.
Functions should deploy same as on my local.
Notice: A new release of pip available: 22.3.1 -> 23.1.2
Notice: To update, run: pip install --upgrade pip
npm WARN exec The following package was not found and will be installed: [email protected]
npm WARN deprecated @npmcli/[email protected]: This functionality has been moved to @npmcli/fs
npm WARN deprecated [email protected]: this library is no longer supported
npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated [email protected]: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
[2023-06-09T22:15:01.093Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[2023-06-09T22:15:01.172Z] [iam] checking project *** for permissions ["cloudfunctions.functions.create","cloudfunctions.functions.delete","cloudfunctions.functions.get","cloudfunctions.functions.list","cloudfunctions.functions.update","cloudfunctions.operations.get","firebase.projects.get"]
[2023-06-09T22:15:01.172Z] >>> [apiv2][query] POST https://cloudresourcemanager.googleapis.com/v1/projects/***:testIamPermissions [none]
[2023-06-09T22:15:01.173Z] >>> [apiv2][(partial)header] POST https://cloudresourcemanager.googleapis.com/v1/projects/***:testIamPermissions x-goog-quota-user=projects/***
[2023-06-09T22:15:01.173Z] >>> [apiv2][body] POST https://cloudresourcemanager.googleapis.com/v1/projects/***:testIamPermissions ***"permissions":["cloudfunctions.functions.create","cloudfunctions.functions.delete","cloudfunctions.functions.get","cloudfunctions.functions.list","cloudfunctions.functions.update","cloudfunctions.operations.get","firebase.projects.get"]***
[2023-06-09T22:15:01.196Z] <<< [apiv2][status] GET https://firebase-public.firebaseio.com/cli.json 200
[2023-06-09T22:15:01.196Z] <<< [apiv2][body] GET https://firebase-public.firebaseio.com/cli.json ***"cloudBuildErrorAfter":1594252800000,"cloudBuildWarnAfter":1590019200000,"defaultNode10After":1594252800000,"minVersion":"3.0.5","node8DeploysDisabledAfter":1613390400000,"node8RuntimeDisabledAfter":1615809600000,"node8WarnAfter":1600128000000***
[2023-06-09T22:15:01.248Z] <<< [apiv2][status] POST https://cloudresourcemanager.googleapis.com/v1/projects/***:testIamPermissions 200
[2023-06-09T22:15:01.249Z] <<< [apiv2][body] POST https://cloudresourcemanager.googleapis.com/v1/projects/***:testIamPermissions ***"permissions":["cloudfunctions.functions.create","cloudfunctions.functions.delete","cloudfunctions.functions.get","cloudfunctions.functions.list","cloudfunctions.functions.update","cloudfunctions.operations.get","firebase.projects.get"]***
[2023-06-09T22:15:01.250Z] >>> [apiv2][query] POST https://iam.googleapis.com/v1/projects/***/serviceAccounts/***@appspot.gserviceaccount.com:testIamPermissions [none]
[2023-06-09T22:15:01.250Z] >>> [apiv2][body] POST https://iam.googleapis.com/v1/projects/***/serviceAccounts/***@appspot.gserviceaccount.com:testIamPermissions ***"permissions":["iam.serviceAccounts.actAs"]***
[2023-06-09T22:15:01.328Z] <<< [apiv2][status] POST https://iam.googleapis.com/v1/projects/***/serviceAccounts/***@appspot.gserviceaccount.com:testIamPermissions 200
[2023-06-09T22:15:01.328Z] <<< [apiv2][body] POST https://iam.googleapis.com/v1/projects/***/serviceAccounts/***@appspot.gserviceaccount.com:testIamPermissions ***"permissions":["iam.serviceAccounts.actAs"]***
=== Deploying to '***'...
i deploying functions
[2023-06-09T22:15:01.335Z] >>> [apiv2][query] GET https://firebase.googleapis.com/v1beta1/projects/*** [none]
[2023-06-09T22:15:01.582Z] <<< [apiv2][status] GET https://firebase.googleapis.com/v1beta1/projects/*** 200
[2023-06-09T22:15:01.582Z] <<< [apiv2][body] GET https://firebase.googleapis.com/v1beta1/projects/*** ***"projectId":"***","projectNumber":"***","displayName":"***","name":"projects/***","resources":***"hostingSite":"***","storageBucket":"***","locationId":"us-central"***,"state":"ACTIVE","etag":"1_a7d5abaf-d82c-4064-9d46-2e0d08b0818d"***
i functions: preparing codebase default for deployment
i functions: ensuring required API cloudfunctions.googleapis.com is enabled...
i functions: ensuring required API cloudbuild.googleapis.com is enabled...
i artifactregistry: ensuring required API artifactregistry.googleapis.com is enabled...
[2023-06-09T22:15:01.584Z] >>> [apiv2][query] GET https://serviceusage.googleapis.com/v1/projects/***/services/cloudfunctions.googleapis.com [none]
[2023-06-09T22:15:01.584Z] >>> [apiv2][(partial)header] GET https://serviceusage.googleapis.com/v1/projects/***/services/cloudfunctions.googleapis.com x-goog-quota-user=projects/***
[2023-06-09T22:15:01.586Z] >>> [apiv2][query] GET https://serviceusage.googleapis.com/v1/projects/***/services/runtimeconfig.googleapis.com [none]
[2023-06-09T22:15:01.586Z] >>> [apiv2][(partial)header] GET https://serviceusage.googleapis.com/v1/projects/***/services/runtimeconfig.googleapis.com x-goog-quota-user=projects/***
[2023-06-09T22:15:01.587Z] >>> [apiv2][query] GET https://serviceusage.googleapis.com/v1/projects/***/services/cloudbuild.googleapis.com [none]
[2023-06-09T22:15:01.588Z] >>> [apiv2][(partial)header] GET https://serviceusage.googleapis.com/v1/projects/***/services/cloudbuild.googleapis.com x-goog-quota-user=projects/***
[2023-06-09T22:15:01.589Z] >>> [apiv2][query] GET https://serviceusage.googleapis.com/v1/projects/***/services/artifactregistry.googleapis.com [none]
[2023-06-09T22:15:01.589Z] >>> [apiv2][(partial)header] GET https://serviceusage.googleapis.com/v1/projects/***/services/artifactregistry.googleapis.com x-goog-quota-user=projects/***
[2023-06-09T22:15:01.877Z] <<< [apiv2][status] GET https://serviceusage.googleapis.com/v1/projects/***/services/runtimeconfig.googleapis.com 200
[2023-06-09T22:15:01.877Z] <<< [apiv2][body] GET https://serviceusage.googleapis.com/v1/projects/***/services/runtimeconfig.googleapis.com [omitted]
[2023-06-09T22:15:01.902Z] <<< [apiv2][status] GET https://serviceusage.googleapis.com/v1/projects/***/services/artifactregistry.googleapis.com 200
[2023-06-09T22:15:01.902Z] <<< [apiv2][body] GET https://serviceusage.googleapis.com/v1/projects/***/services/artifactregistry.googleapis.com [omitted]
โ artifactregistry: required API artifactregistry.googleapis.com is enabled
[2023-06-09T22:15:01.907Z] <<< [apiv2][status] GET https://serviceusage.googleapis.com/v1/projects/***/services/cloudbuild.googleapis.com 200
[2023-06-09T22:15:01.907Z] <<< [apiv2][body] GET https://serviceusage.googleapis.com/v1/projects/***/services/cloudbuild.googleapis.com [omitted]
โ functions: required API cloudbuild.googleapis.com is enabled
[2023-06-09T22:15:01.910Z] <<< [apiv2][status] GET https://serviceusage.googleapis.com/v1/projects/***/services/cloudfunctions.googleapis.com 200
[2023-06-09T22:15:01.911Z] <<< [apiv2][body] GET https://serviceusage.googleapis.com/v1/projects/***/services/cloudfunctions.googleapis.com [omitted]
โ functions: required API cloudfunctions.googleapis.com is enabled
[2023-06-09T22:15:01.911Z] >>> [apiv2][query] GET https://firebase.googleapis.com/v1beta1/projects/***/adminSdkConfig [none]
[2023-06-09T22:15:02.050Z] <<< [apiv2][status] GET https://firebase.googleapis.com/v1beta1/projects/***/adminSdkConfig 200
[2023-06-09T22:15:02.050Z] <<< [apiv2][body] GET https://firebase.googleapis.com/v1beta1/projects/***/adminSdkConfig ***"projectId":"***","storageBucket":"***","locationId":"us-central"***
[2023-06-09T22:15:02.053Z] >>> [apiv2][query] GET https://runtimeconfig.googleapis.com/v1beta1/projects/***/configs [none]
[2023-06-09T22:15:02.277Z] <<< [apiv2][status] GET https://runtimeconfig.googleapis.com/v1beta1/projects/***/configs 200
[2023-06-09T22:15:02.277Z] <<< [apiv2][body] GET https://runtimeconfig.googleapis.com/v1beta1/projects/***/configs ***
[2023-06-09T22:15:02.278Z] Customer code is not Node
[2023-06-09T22:15:02.279Z] Validating python source
[2023-06-09T22:15:02.279Z] Building python source
[2023-06-09T22:15:02.280Z] Could not find functions.yaml. Must use http discovery
[2023-06-09T22:15:02.285Z] Running command with virtualenv: command=., args=["\"/home/runner/work/myapp-web/myapp-web/functions/venv/bin/activate\"","&&","python3.11","-c","\"import firebase_functions; import os; print(os.path.dirname(firebase_functions.__file__))\""]
[2023-06-09T22:15:02.324Z] stdout: /home/runner/work/myapp-web/myapp-web/functions/venv/lib/python3.11/site-packages/firebase_functions
[2023-06-09T22:15:02.329Z] Running admin server with args: ["python3.11","\"/home/runner/work/myapp-web/myapp-web/functions/venv/lib/python3.11/site-packages/firebase_functions/private/serving.py\""] and env: ***"FIREBASE_CONFIG":"***\"projectId\":\"***\",\"storageBucket\":\"***\",\"locationId\":\"us-central\"***","GCLOUD_PROJECT":"***","ADMIN_PORT":"8081"*** in /home/runner/work/myapp-web/myapp-web/functions
[2023-06-09T22:15:02.329Z] Running command with virtualenv: command=., args=["\"/home/runner/work/myapp-web/myapp-web/functions/venv/bin/activate\"","&&","python3.11","\"/home/runner/work/myapp-web/myapp-web/functions/venv/lib/python3.11/site-packages/firebase_functions/private/serving.py\""]
[2023-06-09T22:15:02.926Z] stdout: * Serving Flask app 'serving'
* Debug mode: off
[2023-06-09T22:15:02.928Z] stderr: WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
* Running on http://127.0.0.1:8081
Press CTRL+C to quit
[2023-06-09T22:15:03.191Z] stderr: [2023-06-09 22:15:03,188] ERROR in app: Exception on /__/functions.yaml [GET]
Traceback (most recent call last):
File "/home/runner/work/myapp-web/myapp-web/functions/venv/lib/python3.11/site-packages/flask/app.py", line 2190, in wsgi_app
response = self.full_dispatch_request()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/runner/work/myapp-web/myapp-web/functions/venv/lib/python3.11/site-packages/flask/app.py", line 1486, in full_dispatch_request
rv = self.handle_user_exception(e)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/runner/work/myapp-web/myapp-web/functions/venv/lib/python3.11/site-packages/flask/app.py", line 1484, in full_dispatch_request
rv = self.dispatch_request()
^^^^^^^^^^^^^^^^^^^^^^^
File "/home/runner/work/myapp-web/myapp-web/functions/venv/lib/python3.11/site-packages/flask/app.py", line 1469, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/runner/work/myapp-web/myapp-web/functions/venv/lib/python3.11/site-packages/firebase_functions/private/serving.py", line 120, in get_functions_yaml
functions = get_functions()
^^^^^^^^^^^^^^^
File "/home/runner/work/myapp-web/myapp-web/functions/venv/lib/python3.11/site-packages/firebase_functions/private/serving.py", line 38, in get_functions
spec.loader.exec_module(module)
File "<frozen importlib._bootstrap_external>", line 940, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/home/runner/work/myapp-web/myapp-web/functions/main.py", line 12, in <module>
db = firestore.client()
^^^^^^^^^^^^^^^^^^
File "/home/runner/work/myapp-web/myapp-web/functions/venv/lib/python3.11/site-packages/firebase_admin/firestore.py", line 53, in client
fs_client = _utils.get_app_service(app, _FIRESTORE_ATTRIBUTE, _FirestoreClient.from_app)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/runner/work/myapp-web/myapp-web/functions/venv/lib/python3.11/site-packages/firebase_admin/_utils.py", line 98, in get_app_service
return app._get_service(name, initializer) # pylint: disable=protected-access
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/runner/work/myapp-web/myapp-web/functions/venv/lib/python3.11/site-packages/firebase_admin/__init__.py", line 295, in _get_service
self._services[name] = initializer(self)
^^^^^^^^^^^^^^^^^
File "/home/runner/work/myapp-web/myapp-web/functions/venv/lib/python3.11/site-packages/firebase_admin/firestore.py", line 69, in from_app
credentials = app.credential.get_credential()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/runner/work/myapp-web/myapp-web/functions/venv/lib/python3.11/site-packages/firebase_admin/credentials.py", line 142, in get_credential
self._load_credential()
File "/home/runner/work/myapp-web/myapp-web/functions/venv/lib/python3.11/site-packages/firebase_admin/credentials.py", line 159, in _load_credential
self._g_credential, self._project_id = google.auth.default(scopes=_scopes)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/runner/work/myapp-web/myapp-web/functions/venv/lib/python3.11/site-packages/google/auth/_default.py", line 648, in default
raise exceptions.DefaultCredentialsError(_CLOUD_SDK_MISSING_CREDENTIALS)
google.auth.exceptions.DefaultCredentialsError: Your default credentials were not found. To set up Application Default Credentials, see https://cloud.google.com/docs/authentication/external/set-up-adc for more information.
[2023-06-09T22:15:03.193Z] stderr: 127.0.0.1 - - [09/Jun/2023 22:15:03] "GET /__/functions.yaml HTTP/1.1" 500 -
[2023-06-09T22:15:03.194Z] Got response from /__/functions.yaml <!doctype html>
<html lang=en>
<title>500 Internal Server Error</title>
<h1>Internal Server Error</h1>
<p>The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.</p>
โ functions: Failed to detect functions from source FirebaseError: Failed to parse build specification.
stderr:WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
* Running on http://127.0.0.1:8081
Press CTRL+C to quit
[2023-06-09 22:15:03,188] ERROR in app: Exception on /__/functions.yaml [GET]
Traceback (most recent call last):
File "/home/runner/work/myapp-web/myapp-web/functions/venv/lib/python3.11/site-packages/flask/app.py", line 2190, in wsgi_app
response = self.full_dispatch_request()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/runner/work/myapp-web/myapp-web/functions/venv/lib/python3.11/site-packages/flask/app.py", line 1486, in full_dispatch_request
rv = self.handle_user_exception(e)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/runner/work/myapp-web/myapp-web/functions/venv/lib/python3.11/site-packages/flask/app.py", line 1484, in full_dispatch_request
rv = self.dispatch_request()
^^^^^^^^^^^^^^^^^^^^^^^
File "/home/runner/work/myapp-web/myapp-web/functions/venv/lib/python3.11/site-packages/flask/app.py", line 1469, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/runner/work/myapp-web/myapp-web/functions/venv/lib/python3.11/site-packages/firebase_functions/private/serving.py", line 120, in get_functions_yaml
functions = get_functions()
^^^^^^^^^^^^^^^
File "/home/runner/work/myapp-web/myapp-web/functions/venv/lib/python3.11/site-packages/firebase_functions/private/serving.py", line 38, in get_functions
spec.loader.exec_module(module)
File "<frozen importlib._bootstrap_external>", line 940, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/home/runner/work/myapp-web/myapp-web/functions/main.py", line 12, in <module>
db = firestore.client()
^^^^^^^^^^^^^^^^^^
File "/home/runner/work/myapp-web/myapp-web/functions/venv/lib/python3.11/site-packages/firebase_admin/firestore.py", line 53, in client
fs_client = _utils.get_app_service(app, _FIRESTORE_ATTRIBUTE, _FirestoreClient.from_app)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/runner/work/myapp-web/myapp-web/functions/venv/lib/python3.11/site-packages/firebase_admin/_utils.py", line 98, in get_app_service
return app._get_service(name, initializer) # pylint: disable=protected-access
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/runner/work/myapp-web/myapp-web/functions/venv/lib/python3.11/site-packages/firebase_admin/__init__.py", line 295, in _get_service
self._services[name] = initializer(self)
^^^^^^^^^^^^^^^^^
File "/home/runner/work/myapp-web/myapp-web/functions/venv/lib/python3.11/site-packages/firebase_admin/firestore.py", line 69, in from_app
credentials = app.credential.get_credential()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/runner/work/myapp-web/myapp-web/functions/venv/lib/python3.11/site-packages/firebase_admin/credentials.py", line 142, in get_credential
self._load_credential()
File "/home/runner/work/myapp-web/myapp-web/functions/venv/lib/python3.11/site-packages/firebase_admin/credentials.py", line 159, in _load_credential
self._g_credential, self._project_id = google.auth.default(scopes=_scopes)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/runner/work/myapp-web/myapp-web/functions/venv/lib/python3.11/site-packages/google/auth/_default.py", line 648, in default
raise exceptions.DefaultCredentialsError(_CLOUD_SDK_MISSING_CREDENTIALS)
google.auth.exceptions.DefaultCredentialsError: Your default credentials were not found. To set up Application Default Credentials, see https://cloud.google.com/docs/authentication/external/set-up-adc for more information.
127.0.0.1 - - [09/Jun/2023 22:15:03] "GET /__/functions.yaml HTTP/1.1" 500 -
[2023-06-09T22:15:03.[204](https://github.com/myapp-ai/myapp-web/actions/runs/5226451030/jobs/9437127197#step:6:205)Z] stderr: 127.0.0.1 - - [09/Jun/2023 22:15:03] "GET /__/quitquitquit HTTP/1.1" 200 -
Error: Failed to parse build specification:
- FirebaseError Expect manifest yaml to specify a version number
[2023-06-09T22:15:03.[214](https://github.com/myapp-ai/myapp-web/actions/runs/5226451030/jobs/9437127197#step:6:215)Z] stderr: Terminated
Error: Process completed with exit code 1.