I have previously managed to deploy small projects to firebase hosting with google cloud build. My current project includes functions, but my deploy script is --only:hosting
I understand this is similar to these posts: stackoeverflow1 stackoverflow2 and stackoverflow3 - but I am using functions and kms not secrets, and I have logged in to firebase ci to get my token. Nothing I've seen points the way clearly enough so far!
I am using google kms cryptography and all my permissions are set up correctly. Correct accounts have firebase admin permissions. Trigger variables are defined correctly.
My .env file contains a parameter FIREBASE_TOKEN that I got by doing firebase login:ci
Here is my cloudbuild.yaml
steps:
# Install
- name: 'gcr.io/cloud-builders/npm'
args: ['install']
# Build
- name: 'gcr.io/cloud-builders/npm'
args: ['run', 'build']
#Decrypt
- name: 'gcr.io/cloud-builders/gcloud'
args: ['kms', 'decrypt', '--ciphertext-file=.env.enc', '--plaintext-file=.env', '--location=global', '--keyring=$_KEY_RING', '--key=$_KEY']
# Deploy
- name: 'gcr.io/$_PROJECT_ENV/firebase'
args: ['deploy', '--debug', '--token=$FIREBASE_TOKEN', '--only=hosting:$_DEPLOY_TO', '--project', '$_PROJECT_ENV']
This runs fine until right at the end, when it gives these messages:
Step #3: === Deploying to 'dev-xxxxx'...
Step #3:
Step #3: i deploying hosting
Step #3:
Step #3: ✔ Deploy complete!
Step #3:
Step #3: Project Console: https://console.firebase.google.com/project/dev-xxxxx/overview
Step #3: [2020-09-27T15:51:57.341Z] TypeError: Cannot read property 'deploys' of undefined
Step #3: at /usr/local/lib/node_modules/firebase-tools/lib/deploy/index.js:85:36
Step #3: at processTicksAndRejections (internal/process/task_queues.js:93:5)
Step #3:
Step #3: Error: An unexpected error has occurred.
Tearing my hair out trying to find what could possibly be wrong? Not getting any permissions errors and firebase image is the latest and builds fine? Any suggestions?
This error message might be produced for deployments that don't have the
target
key and value defined in thefirebase.json
file, and for deployments that have incorrecttarget
values.According to the Firebase documentation: