Skip to content

Instantly share code, notes, and snippets.

@manekinekko
Last active August 24, 2023 16:39
Show Gist options
  • Save manekinekko/131820e3c9c9261a56595b5065d2ea76 to your computer and use it in GitHub Desktop.
Save manekinekko/131820e3c9c9261a56595b5065d2ea76 to your computer and use it in GitHub Desktop.
gcloud.tips: deploy cloud function from a Google Cloud Repository

Deploy a Cloud Function from a repository

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 the 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: project-123
  • repository name: default
  • default branch: master
  • function name: function-123

The repository URL should look like this: https://source.developers.google.com/p/project-123/r/default.

Deploying from this repository is quit easy:

$ gcloud beta functions deploy function-123 --source https://source.developers.google.com/projects/project-123/repos/default/moveable-alises/master --entry-point function-123 --trigger-http

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment