GitHub 的 Google Cloud Build integration如果 cloudbuild.yaml
或 Dockerfile
不在存储库的根目录中,则不会检测到它。
当使用包含多个 cloudbuild.yaml
的 monorepo 时,如何配置 GitHub 的 Google Cloud Build 集成来检测正确的 cloudbuild.yaml
?
文件路径:
services/api/cloudbuild.yaml
services/nginx/cloudbuild.yaml
services/websocket/cloudbuild.yaml
Cloud Build 集成输出:
最佳答案
您可以通过一个 gcr.io/cloud-builders/gcloud
步骤在存储库的根目录中添加 cloudbuild.yaml
来完成此操作。这一步应该:
- 遍历每个子目录或使用
find
查找其他cloudbuild.yaml
文件。 - 对于每个找到的
cloudbuild.yaml
,通过运行gcloud builds Submit
来 fork 并提交构建。 - 等待所有 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/