Home > Blockchain >  Using Google Cloud Storage in The Google Cloud Build
Using Google Cloud Storage in The Google Cloud Build

Time:11-27

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; I'd like to add the images to the jekyll output and then upload to firebase with these steps.

Thanks for any guidance provided!

CodePudding user response:

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).

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.

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']

CodePudding user response:

the firebase cli deploy command uses google cloud storage. They package your local files and upload them to cloud storage and the build process takes the files from there.

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.

  • Related