繁体   English   中英

GCP Artifact Registry - 仅在 repo 不存在时创建

[英]GCP Artifact Registry - create repo only when it does not exist

我正在尝试将 repo 创建放在 Github CI/CD 操作中。

但是,我发现我无法重复以下创建命令。

gcloud artifacts repositories create my-repo

如果我在已经有回购协议的情况下执行此操作,操作将完全失败。

只有在没有这样的回购协议时才执行创建的好方法吗?

如果你没有太多的存储库,我会:

  • 使用( 列出存储库)的结果设置一个变量

     gcloud artifacts repositories list|grep my-repo

或者:更具可扩展性,使用gcloud artifacts repositories describe的结果设置变量

gcloud artifacts repositories describe my-repo --location=us-west1
  • 仅当该变量为“1”时才执行 gcloud create 命令(grep 失败,或描述失败)

在此处查看具体的(GitHub 工作流程)示例

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM