Google Cloud Functions:Github发布的项目布局 [英] Google Cloud Functions: Project layout for Github publishing

查看:127
本文介绍了Google Cloud Functions:Github发布的项目布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从Google Cloud Functions开始,我想使用一个真正的编辑器+ github而不是内联编辑器.

I'm starting with Google Cloud Functions, and I want to use a real editor + github instead of the inline editor.

对于现有的Google App Engine Flex(php)项目,我已经对其进行了修改,以便它可以在PubSub上发布有关用户的一些数据.

For an existing Google App Engine Flex(php) project, I've modified it so that it publish on PubSub some data about user.

我想编写一组函数:

  • 一个用于更新BigQuery并发布用户数据已更新的主题的函数
  • 已订阅此更新:几个函数将在BigQueries的查询上运行,并将结果存储在Firebase中(供移动应用程序显示数据统计信息)

以下是一些我找不到答案的基本问题:

Here are some basic questions I couldn't find any answer :

  • 如何组织我的项目?什么是预期的布局,以便GCP可以从github提取项目并运行它?
  • [可选]我可以为一个功能使用多个文件来组织代码吗?

我找到了: https://github.com/PrinceCornNM/generator -firebase-cloud-functions 但我还读到,firebase的功能在stackoverflow帖子上以某种方式不兼容.

I've found this : https://github.com/PrinceCornNM/generator-firebase-cloud-functions but I also read that the Function for firebase was somehow incompatible on a stackoverflow post.

推荐答案

这是我的工作方式:

设置Github存储库

  • 在Githup上创建一个仓库,从我的IDE中签出
  • 创建一个名为"processNewTroncQueteur"函数的文件夹
  • 在此文件夹中创建package.json和index.js,然后从Google Cloud Function复制我的工作函数的内容
  • 提交

以我的存储库为例: https://github.com/dev-mansonthomas/RedCrossQuestCloudFunctions

将我的Github存储库与Google Source Control同步

  • 转到 https://source.cloud.google.com/
  • 新存储库",连接外部存储库"
  • 选择您的GCP项目,然后选择github,选中同意复选框,然后单击连接到GitHub"(按照说明进行操作)
  • 在GitHub上选择项目,然后单击连接选定的存储库"
  • Go to https://source.cloud.google.com/
  • "New Repository", "Connect external repository"
  • Select your GCP Project, then choose github, check the checkbox for consent, and click "Connect to GitHub" (follow instructions)
  • Choose the project on GitHub, and click "Connect Selected Repository"

(我不得不尝试两次,第一次遇到没有详细信息的错误)

(I had to try twice, the first time I got an error without details)

通过源代码管理创建您的云功能

  • 转到 https://console.cloud.google.com/functions/
  • 新功能
  • 选择名称,内存,触发器,运行时和区域(高级)
  • 为源代码"选择云源存储库"
  • 存储库:从"Google Cloud Repository"复制/粘贴存储库名称,当您在存储库中时,可以在屏幕的左上角找到它.对我来说是: github_dev-mansonthomas_RedCrossQuestCloudFunctions
  • 我用过,分行/主用户
  • 带有源代码的目录:文件夹"processNewTroncQueteur"的名称
  • 要执行的功能:"processNewTroncQueteur"
  • 创建,并且我已经对其进行了测试.
  • Go to https://console.cloud.google.com/functions/
  • New Function
  • Choose Name, Memory, Trigger, Runtime, and region (advanced)
  • Choose "Cloud Source Repository" for "Source Code"
  • Repository : Copy/Paste the repo name from "Google Cloud Repository", you can find it, in the upper left corner of the screen, when you're in the repo. For me it's: github_dev-mansonthomas_RedCrossQuestCloudFunctions
  • I used, Branch/Master
  • Directory with source code : the name of the folder 'processNewTroncQueteur'
  • function to execute: 'processNewTroncQueteur'
  • Create, and I've tested it and it works.

这篇关于Google Cloud Functions:Github发布的项目布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆