reselbob
reselbob

Reputation: 415

How to deploy code in an automated way from a branch in BitBucket to a Google Cloud Bucket?

How can move code in an automated way from a branch in BitBucket to a Google Cloud Bucket?

I see a good deal of writing about how to move code into App Engine from BitBucket.

https://blog.bitbucket.org/2014/09/18/google-cloud-push-to-deploy-comes-to-bitbucket/

I am using the Static Web Page feature of Google Bucket to expose the bucket under a predefined subdomain. I want to do a simple copy of files into the bucket and set public access rights on those files when code is merged (committed) to a branch in BitBucket.

Upvotes: 0

Views: 4933

Answers (1)

reselbob
reselbob

Reputation: 415

Problem solved. Turns out the issue was my improper attempts to authenticate into GC Storage using gcloud auth. Here is the bitbucket.pipelines.yml that is working for me right now. (provide your own values for the environment variables.)

pipelines: default: - step: script: - echo "Everything is awesome in general" branches:. staging: - step: script: # Downloading the Google Cloud SDK - curl -o /tmp/google-cloud-sdk.tar.gz https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-155.0.0-linux-x86_64.tar.gz - tar -xvf /tmp/google-cloud-sdk.tar.gz -C /tmp/ - /tmp/google-cloud-sdk/install.sh -q - source /tmp/google-cloud-sdk/path.bash.inc - gcloud -v # package up the application for deployment - echo $GOOGLE_CLIENT_SECRET > client-secret.json - gcloud auth activate-service-account $GOOGLE_ACCOUNT --key-file client-secret.json - gsutil -m cp -r *.html gs://$STAGING_DOMAIN - gsutil -m acl set -R -a public-read gs://$STAGING_DOMAIN - gsutil -m setmeta -h "Cache-Control:private" gs://$STAGING_DOMAIN/*.html

Upvotes: 3

Related Questions