50

?如何写一个GithubApp · Issue #10 · levy9527/blog · GitHub

 4 years ago
source link: https://github.com/levy9527/blog/issues/10?
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Comments

Owner

levy9527 commented on Aug 24, 2019

edited

在继续正文前,先澄清一下:

  1. Github App 是需要部署的,Github 并没有提供托管服务。
  2. 在 Github Marketplace 上架并非使用 Github App 的必要条件。也即,没有在上面展示,你一样可以安装使用自己的 Github App。
  1. npx create-probot-app your-app
  2. cd your-app
  3. yarn dev
  4. register a Github App
  5. install the Github App

实际开发并已上架的App,用于给 pull request 自动打标签:https://github.com/marketplace/auto-add-label

开源地址:https://github.com/levy9527/auto-add-label

进入 https://github.com/settings/apps

image

image

image

进入https://github.com/settings/apps

image

image.png

别忘了,检查下是否订阅了相关事件

image.png

如果在初始化后,并且已经有用户(比如自己)安装了 Github App,再更改权限,则需重新获得用户的授权

重新授权入口如下

image.png

进入后会有提示

image.png

重新授权

image.png

webhooks

可以在 Github App 的 Advanced 页面中查看 webhooks 接收情况

image.png

当然也可以使用 https://smee.io 查看

image.png

image.png

打开项目根目录下的 .env ,复制 WEBHOOK_SECRET 的值

进入 Github App 设置页

image.png

修改 Webhook secret 后保存

image.png

根据经验,每次修改 Webhook 时,最好同时再编辑一次 Webhook secret(即使值没有发生变化),以避免以上情况的发生。

image.png

推荐使用 Heroku:

需要指出的一点是,使用 Heroku 时网络体验稍差,不知道是否是我的网络问题,表现在两个方面:

  1. 我的翻墙工具需要切换为 蓝灯,否则 Heroku Dashboard 几乎无法打开
  2. 在 iTerm2 里使用 Heroku CLI 命令时,很容易出现报错 ENOTFOUND: getaddrinfo ENOTFOUND api.heroku.com api.heroku.com:443 ,需要多次尝试,靠运气成功

可以放心的是,部署后的应用本身,是很稳定的。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK