DEV Community

Soros Liu
Soros Liu

Posted on

📣 Get GitHub follower change notification

My Workflow

As an active user of GitHub, I am always interested in new followers from GitHub, caring a lot about who they are, where are they from, what they do, etc.

So I create a GitHub Action to email me daily, about my follower change events.

Here it is !

GitHub logo Sorosliu1029 / follower-change

📣 Get GitHub follower change event

Follower Change

What this action does ?

Get GitHub follower change event, i.e. when a user follows or unfollows you.

It is not realtime, since GitHub does not provide 'follow' events.

So you may run it periodically as a cron job.

Refer to detailed explanation for how it works.

My own working example:

name: follower notifier
on
  # notify me daily
  schedule:
    - cron: '0 3 * * *' # in UTC time
jobs:
  main:
    runs-on: ubuntu-latest
    steps:
      - name: get follower change
        id: followerChange
        uses: Sorosliu1029/follower-change@v2
        with:
          myToken: ${{ secrets.MY_TOKEN }}
          notifyUnFollowEvent: true
      - name: email me
        uses: dawidd6/action-send-mail@v3
        if: steps.followerChange.outputs.shouldNotify == 'true'
        with:
          server_address: smtp.qq.com
          server_port: 465
          username: ${{ secrets.MAIL_USERNAME }}
          password: ${{ secrets.MAIL_PASSWORD }}
          subject: GitHub Follower Change
          from: Follower Change
…
Enter fullscreen mode Exit fullscreen mode

Submission Category:

Wacky Wildcards

Yaml File or Link to Code

This workflow composites my follower-change action with Send email action

name: follower notifier
on:
  schedule:
    - cron: '0 3 * * *' # in UTC time
  workflow_dispatch:
jobs:
  main:
    runs-on: ubuntu-latest
    steps:
      - name: get follower change
        id: followerChange
        uses: Sorosliu1029/follower-change@v2
        with:
          myToken: ${{ secrets.MY_TOKEN }}
          notifyUnFollowEvent: true
      - name: email me
        uses: dawidd6/action-send-mail@v3
        if: steps.followerChange.outputs.shouldNotify == 'true'
        with:
          server_address: smtp.qq.com
          server_port: 465
          username: ${{ secrets.MAIL_USERNAME }}
          password: ${{ secrets.MAIL_PASSWORD }}
          subject: GitHub Follower Change
          from: Follower Change Notifier
          to: ${{ secrets.TO_EMAIL_ADDRESS }}
          html_body: file://${{ steps.followerChange.outputs.htmlFilePath }}
Enter fullscreen mode Exit fullscreen mode

Additional Resources / Info

Here is how the email looks like, hope you receive it everyday !

Email Screenshot

Top comments (2)

Collapse
 
jcxia43 profile image
Junchen Xia

It's elegant and useful. Nice hack!

Collapse
 
sorosliu1029 profile image
Soros Liu

Thanks !