通过GitHub Repo部署到Google App Engine

时间:2016-12-23 23:24:04

标签: google-app-engine github

我正在学习如何使用Google App Engine,我可以通过终端进行精心部署,但我想让人们为我的github回购做出贡献,他们发布的任何内容都会更新我的应用。这是我的回购:

https://github.com/rajtastic/roshanissuperveryawesome

我已将我的回购同步到应用引擎,我可以看到我的云实例中的内容

enter image description here

我的问题是:

  • 每当我提交回购邮件时,如何部署新版本的应用程序?

有人知道这是否可行?

5 个答案:

答案 0 :(得分:10)

现在看来原来的推送部署功能已弃用,但您可以使用Google Cloud Platform的Build Trigger执行此操作:

导航到Google Cloud Platform>容器注册表>构建触发器并设置要从连接的github存储库自动构建的分支。

确保已向存储库添加了构建定义。 [1]有完整的规范,但这是一个通过gcloud deploy进行cloudbuild.yaml的最低要求的例子:

steps:
- name: 'gcr.io/cloud-builders/gcloud'
  args: ['app', 'deploy']

[1] https://cloud.google.com/container-builder/docs/tutorials/creating-a-custom-build-step

答案 1 :(得分:4)

似乎这是不可能的。看起来您需要通过shell在某个地方进行部署(Google Cloud Shell赢得了工作,我不会认为它可以自动化)。 Codeship.com可以做到这一点,我的工作非常好:

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

答案 2 :(得分:3)

现在应该可以通过 GitHub Actions (2018年10月)实现。

  

GitHub Actions允许您连接和共享容器以运行软件开发工作流程。在GitHub或任何外部系统上以任何语言轻松构建,打包,发布,更新和部署项目,而无需自己运行代码。

请参见 Actions

  

工作流可以由GitHub平台事件(即推送,发布,发布)触发,并且可以运行一系列串行或并行操作作为响应。结合并配置针对社区构建和维护的您所了解和喜爱的服务的操作。

答案 3 :(得分:0)

我已经编写了一个综合性的tutorial ,您可以通过它使用Github Actions在Google Cloud上连续交付Github App。


总而言之,这是您需要的main.workflow配置

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>”
}

答案 4 :(得分:0)

我只是通过使用Google的官方deploy-appengine Github Action来做到这一点。而且实际上很容易:

  • 您需要正确配置 Google云项目。 通过您的GCP控制台,启用App Engine Admin API 并为您的项目设置Service Account
  • 之后,将新服务帐户的密钥注册为GCP_SA_KEY到您的仓库secrets中。
  • 要在存储库中启用Github Actions,请在YALM路径内创建一个.github/workflows文件,并配置其jobs以根据您的需要工作。 (检查official docs以获得语法说明)
  • 因此,请确保在steps之一中添加deploy-appengine动作,可能是在构建项目的另一个动作中

瞧瞧,您的部署自动化正在运行!

Here您可以看到一个完整的示例

告诉我如果您有任何困难,我们将很高兴为您解决问题