【问题标题】:Github action deploy-cloud-functions not building in dependencies?Github action deploy-cloud-functions 没有建立在依赖项中?
【发布时间】:2022-02-17 19:00:45
【问题描述】:

昨天,我试图重组一些 Github CI/CD,因为来自 Google 的操作发出了关于已弃用用法的警告。

其中一个步骤是(构建和)部署 GCP 功能。 要部署的函数的存储库结构如下:

my_proj
  |- .github
  |- src
     |- my_proj
        |- __init__.py
        |- main.py
        |- requirements.txt
...

,带有 requirements.txt 文件

boto3==1.16.54

这里重要的是 requirements.txt,它包含一些依赖项,我也需要发布。

以前,我必须自己构建上传到 GCP 的包,但现在使用“deploy-cloud-functions”操作似乎已经过时了。我根据文档在 Github 中设置了动作:

steps:
  - name: Login to GCP
    uses: google-github-actions/auth@v0
    with:
      credentials_json: ...

  - name: Deploy GCP Function image
    uses: google-github-actions/deploy-cloud-functions@v0
    with:
      name: my_function_name
      runtime: python37
      project_id: ...
      source_dir: ./src/my_proj
      env_vars:
        ...

现在,部署成功了。但是,现在在 GCP 中检查或下载该函数时,其中不包含任何依赖项,并且触发该函数时的日志同样显示由于缺少依赖项而导致函数崩溃。

我还尝试将 requirements.txt 文件移动到项目根目录,但显然无济于事。除了上面链接的 Google 拥有的操作存储库之外,我还没有很幸运地在 Github 中找到有关 GCP 函数工作的大量文档。

谁能在这里发现我的错误?

【问题讨论】:

  • 你能发布你的 requirements.txt 文件吗?您是否使用了一些私有依赖项?
  • 顺便说一句,您将无法在源选项卡中看到您的依赖项二进制文件,但如果您在 Cloud Logging 控制台中查找 resource.type="build",您将能够看到构建日志跨度>
  • 我添加了我的 requirements.txt 内容,这并不疯狂。我会在云控制台中查看您的建议。非常感谢!
  • 我在日志中看到了构建语句!嘘!猜猜,我会回去试验它。非常感谢@DanyelCabello!

标签: python-3.x google-cloud-functions dependencies github-actions


【解决方案1】:

在使用 github actions 部署到 Cloud Functions 时,所有依赖项也会被上传。但是,正如 Danyel Cabello 已经提到的,您将无法在 Google Cloud Console 的 Cloud Functions 的源选项卡中看到依赖项。

要查看构建日志,您可以在 Google Cloud Console 的 Cloud Logging 中搜索 resource.type=“build”

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-04-07
    • 2021-10-25
    • 2018-03-15
    • 2021-07-17
    • 2018-06-06
    • 2019-02-13
    • 2021-11-05
    相关资源
    最近更新 更多