GitHub Action
GitHub follower change event
v2
Latest version
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.
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 Notifier
to: ${{ secrets.TO_EMAIL_ADDRESS }}
# use html file from previous step as email body
html_body: file://${{ steps.followerChange.outputs.htmlFilePath }}
- input:
myToken
: GitHub personal access token with at least 'read:user' and 'repo' scope.⚠️ You should store this token as secret. This input is required.notifyUnFollowEvent
: should notify unfollow event or not. This input is optional, default isfalse
.
- output:
changed
: bool, whether follower changed or not.shouldNotify
: bool, should trigger following steps. Skip notification when no change or first run.htmlFilePath
: string, path of html file for follower change infomarkdown
: string, markdown for follower change infoplainText
: string, plain text for follower change info
The only required secret is MY_TOKEN
, which is used as input myToken
for this action.
You should store your secret at https://github.com/{YOUR_NAME}/{YOUR_REPO}/settings/secrets/actions
, refer to creating encrypted secrets for a repository for more details.
For step 'email me', You could refer to Send mail Github Action
- Use GitHub GraphQL API to get all current followers
- Download previous snapshotted followers from GitHub Action artifact
- Compare current followers with previous followers to get follow and unfollow events
- Upload current followers as new snapshot to GitHub Action artifact
HTML is generated by follower-change-email