首页 > 解决方案 > Firebase 功能部署:带有 Github 操作的未定义环境数据

问题描述

我正在尝试设置 GITHUB 操作来部署我的 firebase 功能。动作的代码是:

name: Development Deploy Workflow
'on':
  push:
    branches:
      - develop
jobs:
  backend-deployment:
    name: Backend Development Deployment
    runs-on: ubuntu-latest
    steps:
      - name: Checkout GitHub repository
        uses: actions/checkout@v2
      - name: Install dependencies
        run: npm install 
      - name: Deploy to Firebase Functions
        uses: w9jds/firebase-action@master
        with:
          args: deploy -P development --only functions           
        env:
          GCP_SA_KEY: '${{ secrets.GCP_SA_KEY }}'

当操作运行时,我收到此错误:

✔  functions: Finished running predeploy script.
i  functions: ensuring required API cloudfunctions.googleapis.com is enabled...
i  functions: ensuring required API cloudbuild.googleapis.com is enabled...
✔  functions: required API cloudbuild.googleapis.com is enabled
✔  functions: required API cloudfunctions.googleapis.com is enabled

Error: Error occurred while parsing your function triggers.

TypeError: Cannot read property 'private_key' of undefined
    at Object.<anonymous> (/github/workspace/lib/services/Firebase.service.js:29:47)

代码行是:

const { private_key } = functions.config().service_account

我不明白为什么functions.config() 是空的,因为我可以毫无问题地从本地机器部署我的函数,并且在三个不同的环境中。谁能帮我?提前致谢。

标签: node.jstypescriptfirebasegithub-actions

解决方案


推荐阅读