google-cloud-platform - GitHub Cloud Build 与 monorepo 中的多个 cloudbuild.yamls 集成
问题描述
GitHub 的Google Cloud Build 集成未检测到cloudbuild.yaml
或Dockerfile
不在存储库的根目录中。
当使用包含多个的 monorepo 时cloudbuild.yamls
,如何配置 GitHub 的 Google Cloud Build 集成以检测正确的cloudbuild.yaml
?
文件路径:
services/api/cloudbuild.yaml
services/nginx/cloudbuild.yaml
services/websocket/cloudbuild.yaml
Cloud Build 集成输出:
解决方案
您可以通过一个步骤cloudbuild.yaml
在存储库的根目录中添加 a 来完成此操作gcr.io/cloud-builders/gcloud
。此步骤应:
- 遍历每个子目录或用于
find
查找其他cloudbuild.yaml
文件。 - 对于每个找到
cloudbuild.yaml
的,通过运行 fork 并提交一个构建gcloud builds submit
。 - 等待所有分叉的
gcloud
命令完成。
在repo的根目录cloudbuild.yaml
中GoogleCloudPlatform/cloud-builders-community
有一个很好的例子。
如果我们去掉非必要的部分,基本上你有这样的东西:
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
推荐阅读
- java - Eclipse Photon:测试套件导致“使用测试运行程序'JUnit 5 找到 Np 测试”。”错误消息
- haskell - 函数中的“上下文”是什么
- python - 如何在 Python 中打印列表的特定元素?
- https - 为 Windows 服务器中托管的网站启用 tpps
- list - 更新列表中的特定项目
- javascript - 通过作为参数传递和全局变量访问函数内部变量之间的区别?
- java - 用 log4j2.xml 初始化 slf4j
- python - Pylintrc 配置仅显示错误
- kubernetes - 重新启动集群时出错:重新启动 kube-proxy:等待 kube-proxy 启动以进行 configmap 更新:等待条件超时
- ffmpeg - LibAV 在文件末尾处理“moov”原子