GitHub 当有人关注我时收到电子邮件

Sle*_*her 5 git email notifications github

也许我错过了一些非常明显的东西,但我进入了我的通知设置,找不到任何关于当人们关注你时收到电子邮件的信息。我可以随时转到我的个人资料上的“关注者”选项卡,查看当前关注我的人,但我想获取更新。

我发现有新人关注我的唯一方法是无意中访问普通的GitHub.com并浏览我的活动。

Von*_*onC 3

您通常会为此创建一个Webhook 。

但对于Follow Event,有记录:

此类事件不再传送,但它们可能存在于某些用户的时间线中。您无法创建侦听这些事件的 Webhook。

另一种方法是设置一个轮询服务,这是一个 cron 作业,它会定期轮询 GitHub 用户以获取关注者数量,并在该数量发生变化时发送电子邮件。


到 2021 年,您将使用GitHub Action,就像Soros Liu所做的那样Sorosliu1029/follower-change

name: "GitHub follower change event"
description: "To get follow and unfollow event, could run as a cron job"
author: "Soros Liu"
branding:
  icon: "user-check"
  color: "green"
inputs:
  myToken:
    description: "github personal access token"
    required: true
  notifyUnFollowEvent:
    description: "should notify unfollow event or not"
    required: false
    default: "false"
outputs:
  changed:
    description: "whether follower changed or not"
  shouldNotify:
    description: "skip notification when no change or first run"
  markdown:
    description: "markdown for follower change info"
  plainText:
    description: "plain text for follower change info"
  htmlFilePath:
    description: "path of html file for follower change info"
runs:
  using: "node12"
  main: "dist/index.js"
Run Code Online (Sandbox Code Playgroud)

怎么运行的 ?

它不是实时的,因为 GitHub 不提供“关注”事件。

因此,您可以将其作为一项作业定期运行cron

  • 使用 GitHub GraphQL API 获取所有当前关注者
  • 从 GitHub Action 工件下载之前的快照关注者
  • 将当前关注者与之前的关注者进行比较以获取关注和取消关注事件
  • 将当前关注者作为新快照上传到 GitHub Action 工件

结果:

新的关注者