Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding git hooks to google cloud repo

One of the things that comes with google cloud are git repos. Is it possible to add hooks to this repo? I'd like to incoming pushes, but I don't know how to get access to .git/hooks.

like image 846
pythonic metaphor Avatar asked Jun 14 '16 17:06

pythonic metaphor


2 Answers

You can do it if you host your code on git-hub/bitbucket. Then you will be able to use the git hooks.

Google source has this feature (Object Change Notification) instead of hooks: https://cloud.google.com/storage/docs/object-change-notification

like image 177
CodeWizard Avatar answered Oct 11 '22 15:10

CodeWizard


You can use the pub/sub notifications instead of the webhook.

In my case, I created a pub/sub which is triggered when the repository is updated. The pub/sub will call a cloud function that makes a post request to codemagic.io CI/CD to initiate a cloud build.

pub/sub notification: https://cloud.google.com/source-repositories/docs/quickstart-adding-pubsub-notifications

You can get the information like the updated branch name, author, etc, in the notification payload. https://cloud.google.com/source-repositories/docs/pubsub-notifications#notification_example

like image 23
Soorya Avatar answered Oct 11 '22 15:10

Soorya