如何保持存储桶与 Google Cloud Source Repository 同步

问题描述 投票:0回答:2

问题:

Google 是否会自动将更改推送到项目的云源存储库来更新存储桶?

示例:

我创建了一个名为 Cooking 的 Google Cloud Platform 项目,并将文件 recipe.txt 存储在存储桶中。

我修改 recipe.txt 并将更改从本地主分支推送到云源存储库以进行 Cooking

当我查看项目的源代码面板时,我看到 recipe.txt 已更新为我的最新更改。

当我查看项目的存储桶时,我发现 recipe.txt 不是最新的(即与项目的云源存储库不同步)。

google-cloud-storage google-cloud-platform google-cloud-repository
2个回答
2
投票

不。 Google Cloud Source Repositories 可以配置为与其他 git 存储库服务(例如 GitHub 或 Bitbucket)保持同步,但 Google Cloud Source Repository 存储库和 GCS 存储桶之间没有关系。


0
投票

虽然问题与标题不同,但我将回答如何使 Cloud Storage 存储桶与 Cloud Source Repository 保持同步。

这可以通过使用Cloud Build来实现。在推送到主分支时创建构建触发器(或任何其他事件,请参阅 Cloud Build 文档)。

假设云源存储库中包含

recipe.txt
的文件夹的路径为
./path/to/folder
并且您希望将该文件夹的内容与存储桶
your-bucket
同步,请使用以下
yaml
构建配置:

steps:
  - name: gcr.io/cloud-builders/gsutil
    args:
      - rsync
      - '-r'
      - '-d'
      - ./path/to/folder
      - 'gs://your-bucket/'

(查看什么

rsync
及其选项是:https://cloud.google.com/storage/docs/gsutil/commands/rsync

© www.soinside.com 2019 - 2024. All rights reserved.