简体   繁体   English

在 Google Cloud Build 中使用 Google Cloud Storage

[英]Using Google Cloud Storage in The Google Cloud Build

According to the documentation google cloud build can build from google cloud storage or a repository.根据文档,谷歌云构建可以从谷歌云存储或存储库构建。 But I'm having a hard time finding documentation on how to use files I upload to google cloud storage in the build steps.但是我很难找到有关如何在构建步骤中使用我上传到谷歌云存储的文件的文档。 My intention is for a website where my jekyll source code is in the repository and my images are in google cloud storage;我的目的是建立一个网站,我的 jekyll 源代码在存储库中,我的图像在谷歌云存储中; I'd like to add the images to the jekyll output and then upload to firebase with these steps .我想将图像添加到 jekyll output 然后通过这些步骤上传到 firebase 。

Thanks for any guidance provided!感谢您提供的任何指导!

the firebase cli deploy command uses google cloud storage. firebase cli deploy 命令使用谷歌云存储。 They package your local files and upload them to cloud storage and the build process takes the files from there.他们 package 您的本地文件并将它们上传到云存储,构建过程从那里获取文件。

I don't think they thought about the process of 'merging' your repo files and files from cloud storage.我认为他们没有考虑从云存储中“合并”您的回购文件和文件的过程。

But you use the steps configuration for cloud build and have 1 step downloading assets from cloud storage with the gcloud cli.但是您使用步骤配置进行云构建,并使用 gcloud cli 从云存储中下载资产的 1 步。

For a step in Cloud Build to copy files you would provide your Cloud Build service account with IAM permission to read the files in the bucket (probably something like: roles/storage.objectViewer).对于 Cloud Build 中复制文件的步骤,您需要为您的 Cloud Build 服务帐号提供 IAM 权限以读取存储桶中的文件(可能类似于:roles/storage.objectViewer)。

Once the Service Account used by Cloud Build can read the files you would create a step to pull the files in before your step to deploy to Firebase.一旦 Cloud Build 使用的服务帐户可以读取文件,您将创建一个步骤以在部署到 Firebase 之前将文件拉入。

A rough example:一个粗略的例子:

steps: 
  - name: 'gcr.io/cloud-builders/gsutil'
    args: ['cp', 'gs://$MY_BUCKET/*.jpg', '.']

  - name: gcr.io/$PROJECT_ID/firebase
    args: ['deploy', '--project=$PROJECT_ID', '--only=hosting']

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

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