A very warm welcome to all the code committers out there working day in & out with GitHub ?
How are you? Welcome to 8bitmen.com

This write-up is an insight into Probot, a framework for developing apps for GitHub. And GitHub Apps as a whole.

So, without any further ado. Let’s get on with it.

 

1. What is Probot? How Does it Help in Creating GitHub Apps?

Probot is a framework for creating bots in NodeJS for automating & improving workflows on GitHub. Github apps, we can also call them bots, extend the functionality of the portal in big ways.

They take care of the can be programmed tasks like closing long open issues, welcoming new users, setting reminders on issues & pull requests etc.

If you’ve ever logged into Discord, you will kind of relate to what I am talking about.

Discord servers heavily use bots to automate stuff.

 

Alright, So didn’t we have a GitHub API & an SDK already for creating apps? Why a new framework? What’s the deal?

Yeah, well. I agree, initially, we wrote GitHub Apps via the SDK made available by GitHub. Using their REST API, GraphQL & Webhooks. But when doing that there were things which were a bit of a hassle & would slow us down a bit like authentication, receiving & validating web hooks etc.

Probot abstracts away all the nitty-gritty, the obvious stuff, in the code required to create a GitHub app. Like the boilerplate functionalities.

It handles the authentication & integration automatically, enables the webhook & event registration, easily handles the events triggered manually, during code commit or the issue creation. Thus, speeding up the app development process.

The complexity of building & integrating apps with GitHub is toned down by a large extent. Instead of so many things, it’s just one simple framework for communicating with GitHub.

Cool stuff!!

 

More on Probot

The framework is used by GitHub a lot. Like by Github employees & open source developers. Electron & Atom use it for automating stuff in their repositories.

Also, the framework is continually under rapid development & evolution by the passionate open source community.

Github apps can be built entirely on Probot. Just give a private key to your app to interact directly with GitHub. It handles all the security for you, simplifying the API interaction.

It provides permissions to apps for the data at a really granular level. Providing only the data which apps need & nothing more.

Developers can now focus on what they want to build, instead of spending time writing boilerplate code.

With a really simple API built on the latest ES6 JavaScript features. Probot hides the details you don’t care about.

If you are still with me, let’s dig a little more into GitHub Apps. Why are they really required? 

 

2. What is the Need for GitHub Apps?

In the above part of the article, I explained why Probot over regular GitHub apps? In this section, I will talk about why write GitHub apps at all?

Well, it’s a pretty interesting fact that Github has more API traffic than UI traffic. Devs are interacting with the platform via APIs & when we use an API, we put on our creative thinking hats for new features & possibilities.

So, Say, you want a functionality in GitHub to send you a Hi-Five message every time you successfully merge a pull request to the master or when you push, all your work, to the branch at the end of the day.

Now GitHub has a limited set of features by default. We can’t expect everything of it. That would be too demanding of us.

Well, we can think of searching for the feature we want in the GitHub marketplace.

What is GitHub Marketplace?

GitHub marketplace is a store for apps, developed by the community, extending the features of the platform. It contains both free & paid apps which are safe, secure & well tested.

Now, what if we don’t find the feature there?

We might as well look into Works with GitHub. It’s a store for the products that integrate with the platform.

Still no luck. We are left with no other option than writing the functionality from scratch. Hence the need for GitHub Apps. Build what you want to.

 

3. Building Apps with GitHub


Apps are first class actors in GitHub. What do I mean by that?

App or bots perform the assigned task just like any other human repo moderator. On the UI they’ll look like regular user profiles, just with a bot tag with them.


3.1 How GitHub Apps Work? GitHub Webhooks & Events

GitHub apps are triggered via Events. What is an Event?

An event can be anything from pushing the code to a branch to merging a pull request to the master to commenting on a discussion. Apps are hooked on to the GitHub platform via Webhooks.

So, when an event occurs on GitHub. It sends an HTTP POST Payload to the webhook’s configured url. Webhooks then send a signal to the bot & the bot performs the assigned task. Apps can choose events what they want to react to.

I can also rephrase this as Github apps are subscribed to events on the platform via Webhooks.

 

Now you may ask, what is a payload?

A payload is an information relevant to the event sent via the HTTP POST request.

Probot takes care of managing the authentication between the platform & the app, also the webhooks.

GitHub recommends using a test-driven style of development when writing GitHub apps. This helps us dodge the hassle of continuously creating real GitHub events to test the app. By writing our test first we can certainly avoid re-creating real events on GitHub to test if our code works fine.

 

Ohk… Now Let’s take a look into some of the Probot apps already made available to us by the community.

 

4. Probot App Examples

Majority of the Probot apps are hosted, so there’s nothing for us to deploy and manage. Here are just a few examples of open source & free to use on any project apps, built on Probot.


4.1 Work in Progress WIP

This app prevents the inadvertent merge of pull requests with WIP Work in Progress in the title. It’s used by repos of Electron, Flutter, Stack Exchange etc.


4.2 Stale

This app automatically closes stale issues & pull requests which accrue up in a project over a long period of time. Used by Facebook, Homebrew, Shopify, Atom etc.


4.3
Welcome

This bot welcomes new users to the repo. Well, I would never mind a warm welcome ?
It is used by VueJS, WebTorrent etc.


4.4 First Timers

This bot helps in onboarding new contributors to a repo by helping them with useful resources, starter guides & stuff.

 

There are a plethora of Probot apps available on GitHub. An entire army of GitHub NodeJS robots.

 

More on the Blog

How to Pick the Right Architecture For Your App – Explained With Use Cases

A Practical Guide to Picking the Right Cloud Provider for Your Application

A Thorough Insight into What is a Cloud Architect? And Why Should You Become One?

What Is Wercker? Why Use It? Everything You Should Know

Difference Between Centralized, Decentralized & Distributed Systems Oversimplified

How Hotstar scaled with 10.3 million concurrent users – An architectural insight

 

Well, Guys, this was pretty much it on GitHub Apps & Probot. If the write-up helped your understanding of GitHub apps in anyway. Do let me know in the comments. If yes it is completely worth writing it.

Do share it with your Geek friends, programmers, who work with Git & GitHub day in & out.

See you in the next write-up.
Until then…
Cheers