代码之家  ›  专栏  ›  技术社区  ›  sabrehagen

GitHub云构建与monorepo中的多个Cloud Build.yaml的集成

  •  8
  • sabrehagen  · 技术社区  · 7 年前

    GitHub的 Google Cloud Build integration 未检测到 cloudbuild.yaml Dockerfile

    当使用包含多个 cloudbuild.yamls ,如何配置GitHub的Google云构建集成来检测正确的 云构建.yaml

    文件路径:

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

    云构建集成输出:

    Failed build

    3 回复  |  直到 6 年前
        1
  •  20
  •   Rohan Singh    6 年前

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

    1. 遍历每个子目录或使用 find 云构建.yaml 文件夹。
    2. 云构建.yaml ,派生并通过运行提交生成 gcloud builds submit .
    3. 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
    
        2
  •  2
  •   Clint    6 年前

    关键是不仅要检测更改,还要检测依赖于该更改的任何服务。我们正在做的是:

    • 要求每个服务都有一个带有build命令的MAKEFILE。
    • 将cloudbuild.yaml放在mono repo的根目录中
    • 然后,我们使用这个小工具运行一个定制的构建步骤(旧的但似乎仍然有效) https://github.com/jharlap/affected
    • 然后shell脚本将运行 make build 任何受更改影响的服务。

    许多人使用的另一个选择是巴泽尔。不是最简单的工具,但是如果你有很多不同的语言或者在你的mono repo中构建进程的话,那就特别好了。

        3
  •  -3
  •   Max Mikhaylov    6 年前

    您可以创建 build trigger 为您的存储库。设置触发器时 cloudbuild.yaml 对于生成配置,需要提供 在存储库中。