How to keep storage bucket synced with Google Cloud Source Repository - google-cloud-storage

Question:
Does Google automatically update storage buckets with changes pushed to a project's Cloud Source Repository?
Example:
I create a Google Cloud Platform project called Cooking and store the file recipe.txt in a bucket.
I modify recipe.txt and push the changes from my local master branch to the Cloud Source Repository for Cooking.
When I look at the Source Code panel for my project, I see recipe.txt is up-to-date with my latest changes.
When I look at the storage bucket for my project, I see recipe.txt is not up-to-date (i.e. not in sync with the project's Cloud Source Repository).

No. Google Cloud Source Repositories can be configured to stay in sync with other git repository services, such as GitHub or Bitbucket, but there is no relationship between Google Cloud Source Repository repositories and GCS buckets.

Related

How to make my Github master branch the only branch to be authorised to access Production resources on GCP?

I use Github for version control and Google Cloud Platform to orchestrate my resources and store data. I use Kubernetes (google cloud platform) and Jenkins to execute my scripts. BigQuery, Google Cloud Storage (buckets), Cloud MySQL to store my data.
I have a master branch which has production codes and development branch which has development codes. Is there a way how I can restrict only master branch codes to have write access to Production resources on Google Cloud Platform.

Github webhook is not created when creating a Google Cloud Build trigger

I have many projects which uses Google Cloud Build + Github build pipeline setup. However, there is this one project, which I cannot create a webhook in Github for.
It used to work - but commits to the repository doesn't trigger the build process any more. I deleted the trigger and added it again - but the webhook in Github is not created automatically for this project.
When I run the trigger manually, it picks the wrong, but fixed commit which I did before an year.
Any clue?
Could you try delete a repository on Cloud Source Repositories and setup Google Cloud Build again ?
See:
https://cloud.google.com/cloud-build/docs/running-builds/automate-builds
Note: For external repositories, such as GitHub and Bitbucket, you must have owner-level permissions for the Cloud Platform project with which you're working. When you set up a build trigger with an external repository for the first time, you'll need to set up authorization with that repository.
After you've set up your external repository, Cloud Source Repository creates a mirror of your repository.
https://source.cloud.google.com
https://cloud.google.com/source-repositories/docs/deleting-a-repository
https://cloud.google.com/source-repositories/docs/mirroring-a-github-repository
I am experiencing the same issue. I can create a trigger for a repo, but I cannot connect the repo automatically to cloud build. We also have many projects, and this manual labor is sort of annoying.
Is there any (under the hood) github/gcloud api available in which I can connect a github repo to cloud build? I am aware that this can only be done by someone with admin privileges on a repo or organization in github.
After this, I will be able to run the command gcloud build triggers create github [NAME]

Cloud Build Trigger Settings have stale, out-of-date GitHub branch data

We installed the Google Cloud Build GitHub app. We then created some Build Triggers with the Google Cloud Build web user interface. This worked for a while.
Recently we pushed new branches to our GitHub repositories and tried to create Google Cloud Build Triggers for those branches. The Trigger Settings page says "No branch matches" even though we are 100% sure that the branch exists on GitHub.
How can we refresh the branch listings in the Google Cloud Build Trigger Settings page?
We have tried logging in/out of Google Cloud Build and GitHub. We have also tried uninstalling and re-installing the Google Cloud Build GitHub app. We have also tried simply waiting for a few hours.
The problem was that, while configuring Cloud Build with GitHub, we had pushed too many buttons.
This is an overview of what we needed to reset.
In GitHub
Go to the affected repository.
Open its settings.
Delete the Webhook associated with source.developers.google.com/webhook/github.
Delete the Deploy key associated with Google Connected Repository Fingerprint.
In Google Cloud Console (console.cloud.google.com)
Open Source Repositories
Disconnect the mirror of the affected repository.
Open Cloud Build
Delete and recreate the Build Trigger(s) for the affected repository.
Aside re: the Google Cloud Build GitHub App
Setting up specific triggers in Google Cloud Build is orthogonal to using the Google Cloud Build GitHub app. The former does not require the latter. They are different ways to do similar things.
If you had installed the Google Cloud Build GitHub App in your GitHub account because you thought it was required for Google Cloud Build Triggers, then uninstall the Google Cloud Build GitHub App. It works differently than setting up specific Google Cloud Build triggers does, and I found it quite confusing to have both running.

Google cloud source repository - Control access to master branch

How would one control access to the master branch in google cloud source repository so that developers don't have access to commit to master branch ?
We don't yet have per-branch permissions, but it's definitely something we're considering for the future.
Chris Sells
PM, Google Cloud Source Repositories

Accessing Google Cloud Source Repositories from Google Cloud Storage

Is possible to access or copy (transfer) a git Google Cloud Source repository to Google Cloud Storage.
The idea is to use the git repo as a website like GitHub Pages.
You can do this as follows:
clone the Google Cloud Source repo
use gsutil cp -r dir1/dir2 gs://my_bucket/subdir to copy the contents of the data to Google Cloud Storage, possibly after processing (e.g., if you want to use something like Jekyll or Middleman to generate your website). Note that this will also copy your .git directory as well, which you might want to exclude.