14

I'm learning how to use Google App Engine and I can deploy fine via terminal but I want to allow people to contribute to my github repo and anything they publish will update my app. Here is my repo:

https://github.com/rajtastic/roshanissuperveryawesome

I've sync'd my repo to app engine and I can see the contents in my Cloud instance

enter image description here

My question is:

  • How do I deploy a new version of my app whenever I commit to my repo?

Does anyone know if this is possible?

Blue
  • 22,608
  • 7
  • 62
  • 92
Rajtastic
  • 187
  • 1
  • 1
  • 9
  • Possible duplicate of [How can I deploy direct from Google Cloud Source Repository to Google App Engine?](http://stackoverflow.com/questions/40490073/how-can-i-deploy-direct-from-google-cloud-source-repository-to-google-app-engine) – Dan Cornilescu Dec 24 '16 at 19:53
  • You should rollback your change and add that as an answer, to not leave the question unanswered – Dan Cornilescu Dec 29 '16 at 16:24
  • 1
    Thanks @DanCornilescu, rolled back and answered – Rajtastic Jan 01 '17 at 17:00
  • *allow people to contribute to my github repo and anything they publish will update my app* this is the worst idea I have seen in a long time. –  Sep 30 '17 at 04:32
  • Hey @Rajtastic, check [this answer](https://stackoverflow.com/a/64979712/2989289) to see if you can solve this! – artu-hnrq Apr 12 '21 at 20:13

5 Answers5

12

Looks like the original push-to-deploy feature is now deprecated, but you can use Google Cloud Platform's Build Trigger to do this:

Navigate to Google Cloud Platform > Container Registry > Build Triggers and set up the branch(es) you want to auto build from your connected github repository.

Make sure you've added a build definition to your repository. Here you can find the full specification, but here's an example of the bare minimum to do a gcloud deploy via cloudbuild.yaml:

steps:
- name: 'gcr.io/cloud-builders/gcloud'
  args: ['app', 'deploy']
artu-hnrq
  • 1,343
  • 1
  • 8
  • 30
Justin
  • 500
  • 8
  • 18
  • 4
    Using Google Could Build via its GitHub App to deploy to App Engine worked really well for me, but there are more steps you need to do than are outlined here or in the link above. I wrote this summary of what you need to do https://leighmcculloch.com/posts/continuous-deployment-to-app-engine-using-google-cloud-build/. – Leigh McCulloch Jan 06 '19 at 03:01
  • Doesn't work anymore unfortunately @LeighMcCulloch :( Adding that IAM member returns the error: "Email addresses and domains must be associated with an active Google Account, G Suite account, or Cloud Identity account." – NaturalBornCamper Apr 09 '21 at 01:13
  • @NaturalBornCamper that error usually indicates the email you're using is invalid, such as has a typo or isn't connected to any account. This setup still works for me. – Leigh McCulloch Apr 10 '21 at 02:57
5

That should be possible now with GitHub Actions (Oct. 2018).

GitHub Actions allows you to connect and share containers to run your software development workflow. Easily build, package, release, update, and deploy your project in any language—on GitHub or any external system—without having to run code yourself.

See Actions:

Workflows can be triggered by GitHub platform events (i.e. push, issue, release) and can run a sequence of serial or parallel actions in response. Combine and configure actions for the services you know and love built and maintained by the community.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
3

it seems that this is not possible. It looks like you need to deploy via a shell somewhere (Google Cloud Shell won't work I don't think as it can't be automated). Codeship.com can do it and I have it working very nicely:

https://documentation.codeship.com/basic/continuous-deployment/deployment-to-google-app-engine/


Rajtastic
  • 187
  • 1
  • 1
  • 9
3

I have written a comprehensive tutorial that you can follow to achieve continuous delivery of your Github App on Google Cloud with Github Actions.


In summary, here is the main.workflow configuration you need

workflow “build & deploy” {
 resolves = [“gcloud deploy”]
 on = “push”
}
action “filter master” {
 uses = “actions/bin/filter@master”
 args = “branch master”
}
action “install node_modules” {
 uses = “nuxt/actions-yarn@master”
 needs = [“filter master”]
 args = “install”
}
action “build static files” {
 uses = “nuxt/actions-yarn@master”
 needs = [“install node_modules”]
 args = “build”
}
action “gcloud auth” {
 uses = “actions/gcloud/auth@master”
 secrets = [“GCLOUD_AUTH”]
 needs = [“build static files”]
}
action “gcloud deploy” {
 uses = “actions/gcloud/cli@master”
 needs = [“gcloud auth”]
 runs = “gcloud app deploy — project=<PROJECT-ID>”
}
Lyubomir
  • 19,615
  • 6
  • 55
  • 69
2

I just did that works through the use of Google's official deploy-appengine Github Action. And it's actually quite easy:

  • You will need to have a Google Cloud Project properly configured. Through your GCP console, enable the App Engine Admin API and also setup a Service Account to your project
  • After that, register the new Service Account's key into your repo secrets as GCP_SA_KEY.
  • To enable Github Actions in your repository, create a YALM file inside .github/workflows path and configure its jobs to work according your desire. (Check official docs for syntax instructions)
  • Thus, make sure to include the deploy-appengine action in one of its steps, probably after another that builds your project

And voilà, your deploy automation is working!

Here you can see a complete example

Tell me if you have any difficulties, I'll be glad to help you solve this

artu-hnrq
  • 1,343
  • 1
  • 8
  • 30