Skip to Content

Deploy a Cloud Function from a Git source repository

Using Google Source Repository

Posted on One min read

Google Cloud Functions allows you to deploy small logical units of code (i.e. functions). While it is already possible to deploy these functions from a Google Cloud Storage bucket or directly from the inline editor (e.g. for prototyping purposes), did you know that you can take advantage of Google Cloud Repository to host the Cloud Functions source code and automate these deployments? You could for instance trigger a new deploy after each git push.

Let’s see how.

We’ll assume you already have a working Google Cloud Repository (how to setup a Cloud Repository) with the following configuration:

  • projectID: project123
  • repository name: myrepo
  • myrepo branch: master
  • function name: fnName

The repository URL should look like this:

Deploying from this repository is quite easy:

$ gcloud beta functions deploy fnName \
    --source \
    --entry-point fnName --trigger-http

Note: Please note that the --source URL used to deploy the function is different from the repository URL!

comments powered by Disqus