google-cloud-platform - GitHub Cloud Build 与 monorepo 中的多个 cloudbuild.yaml 集成

标签 google-cloud-platform monorepo google-cloud-build

GitHub 的 Google Cloud Build integration如果 cloudbuild.yamlDockerfile 不在存储库的根目录中,则不会检测到它。

当使用包含多个 cloudbuild.yaml 的 monorepo 时,如何配置 GitHub 的 Google Cloud Build 集成来检测正确的 cloudbuild.yaml

文件路径:

services/api/cloudbuild.yaml
services/nginx/cloudbuild.yaml
services/websocket/cloudbuild.yaml

Cloud Build 集成输出:

Failed build

最佳答案

您可以通过一个 gcr.io/cloud-builders/gcloud 步骤在存储库的根目录中添加 cloudbuild.yaml 来完成此操作。这一步应该:

  1. 遍历每个子目录或使用 find 查找其他 cloudbuild.yaml 文件。
  2. 对于每个找到的 cloudbuild.yaml,通过运行 gcloud builds Submit 来 fork 并提交构建。
  3. 等待所有 fork 的 gcloud 命令完成。

the root cloudbuild.yaml 中有一个很好的示例说明了一种方法。 the GoogleCloudPlatform/cloud-builders-community repo内.

如果我们去掉非必要的部分,基本上你会得到这样的东西:

steps:
- name: 'gcr.io/cloud-builders/gcloud'
  entrypoint: 'bash'
  args:
  - '-c'
  - |
    for d in */; do
      config="${d}cloudbuild.yaml"
      if [[ ! -f "${config}" ]]; then
        continue
      fi

      echo "Building $d ... "
      (
        gcloud builds submit $d --config=${config}
      ) &
    done
    wait

关于google-cloud-platform - GitHub Cloud Build 与 monorepo 中的多个 cloudbuild.yaml 集成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51861870/

相关文章:

google-cloud-build - 是否可以从由 GCB 步骤构建和启动的容器访问服务帐户凭据?

google-cloud-platform - Google Cloud 构建 10 分钟后超时

google-app-engine - 限制/减少 App Engine Flex 实例中的核心数量

monorepo - Codecov 无法识别 codecov.yml 配置中的标志

javascript - 将包链接为 Lerna 包依赖项以进行开发

javascript - 如何修复 Lerna Monorepo 中的 VSCode 导入路径建议?

docker - 使用gcp cloud build创建dockerfile时出错

java - 如何通过 google api 库(例如 people api)或带有服务帐户凭据的 REST 通过 google 电子邮件获取用户信息(account_id)?

firebase - 即使 Firestore 中发生错误,如何使监听器保持附加状态?

mysql - 为什么我在连接到 Cloud sql 的 gke 虚拟机上安装的 WordPress 停留在步骤 2?