GitHub Cloud Build 与 monorepo 中的多个 cloudbuild.yaml 集成 [英] GitHub Cloud Build Integration with multiple cloudbuild.yamls in monorepo

查看:17
本文介绍了GitHub Cloud Build 与 monorepo 中的多个 cloudbuild.yaml 集成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

GitHub 的

解决方案

您可以通过在存储库的根目录中添加一个 cloudbuild.yaml 并使用一个 gcr.io/cloud-builders/gcloud 步骤.这一步应该:

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

中有一个很好的例子说明了一种方法可以做到这一点cloudbuild.yaml 位于 GoogleCloudPlatform/cloud-builders-community repo.

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

步骤:- 名称:'gcr.io/cloud-builders/gcloud'入口点:'bash'参数:- '-C'- |对于 d 在 */;做config="${d}cloudbuild.yaml"如果 [[ !-f "${config}" ]];然后继续菲echo "正在建造 $d ... "(gcloud 构建提交 $d --config=${config}) &完毕等待

GitHub's Google Cloud Build integration does not detect a cloudbuild.yaml or Dockerfile if it is not in the root of the repository.

When using a monorepo that contains multiple cloudbuild.yamls, how can GitHub's Google Cloud Build integration be configured to detect the correct cloudbuild.yaml?

File paths:

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

Cloud Build integration output:

解决方案

You can do this by adding a cloudbuild.yaml in the root of your repository with a single gcr.io/cloud-builders/gcloud step. This step should:

  1. Traverse each subdirectory or use find to locate additional cloudbuild.yaml files.
  2. For each found cloudbuild.yaml, fork and submit a build by running gcloud builds submit.
  3. Wait for all the forked gcloud commands to complete.

There's a good example of one way to do this in the root cloudbuild.yaml within the GoogleCloudPlatform/cloud-builders-community repo.

If we strip out the non-essential parts, basically you have something like this:

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

这篇关于GitHub Cloud Build 与 monorepo 中的多个 cloudbuild.yaml 集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆