All the self-help gurus keep telling you that you should control your instincts and avoid checking your GitHub projects to see if somebody starred any of them in the last 5 minutes. I have the same problem (yes, first world problems). And as usual, changing the system/environment is easier than changing your own behaviour. That’s why I’ve changed the approach to check for stars counting from a pull to a push project thanks to Xatkit.
Now, instead of me checking GitHub for new notifications, I have a bot that alerts me automatically every time somebody stars one of my projects, as you can see in the featured image above. By using our (now extended) Xatkit-GitHub platform, creating this bot is as easy as writing the following four lines of code:
Basically, we subscribe to the Star_Event and extract out of the JSON Payload sent by GitHub all the data we want to integrate into our message. The reception of the event, the parsing of the JSON data,… is all done by the GithubPlatform.GithubWebhookEventProvider class. We just take what we need from the processed information. As usual, in this example we post the result on Slack but this is up to you, just make sure you configure the properties file.
Note that the bot can also be the bearer of bad news. If some lesser person decides to unstar a repo you’ll get also the proper notification. In both cases, the alert is immediate since we process the GitHub events as they come.
Our Xatkit-GitHub platform is bidirectional. Beyond subscribing to GitHub events we can also call GitHub ourselves to create new issues, add labels, users,… based on a chat conversation taking place on an external platform. We have another example for this: Talk with your repositories – A Slack chatbot for GitHub. See this and other examples in our dedicated xatkit examples repo.
I hope these examples show you how powerful can this integration between Xatkit and GitHub be. Surprise us with your own examples!.