从 Google Cloud Build 部署 Firebase 函数时出现问题

问题描述 投票:0回答:1

部署“托管”的说明似乎超级简单,只是:

args: ['deploy', '--project=project-id', '--only=hosting']

现在,我想部署托管和功能,所以我删除了“--only=hosting”,但这失败了,因为:

  • 找不到 venv (
    Error: Failed to find location of Firebase Functions SDK. Did you forget to run '. "/workspace/XXX/functions/venv/bin/activate" && python3.12 -m pip install -r requirements.txt'?
    )
  • 云构建步骤定义中的环境变量丢失 (
    Error: In non-interactive mode but have no value for the following environment variables
    )
firebase google-cloud-functions google-cloud-build
1个回答
0
投票

这是我最终用来部署我的 firebase 函数的 cloudbuild.yml

google cloud build
:

steps:
  - name: gcr.io/XXX/firebase
    env:
      - ENV1=1
    args:
      - '-c'
      - |
        set  &&
        env | grep -E "ENV1|SECRETENV" > functions/.env &&
        python3 -m venv functions/venv &&
        . functions/venv/bin/activate &&
        python -m pip install -r functions/requirements.txt &&
        firebase deploy --project=XXXX
    dir: blah
    entrypoint: /bin/bash
    secretEnv:
      - SECRETENV
timeout: 600s
availableSecrets:
  secretManager:
    - versionName: projects/XXX/secrets/XXXX/versions/latest
      env: SECRETENV
© www.soinside.com 2019 - 2024. All rights reserved.