This guide will walk you through running a simple GitHub App that ensures every commit has the word bananas and get it running on a test repository. All of the source code you need is in this gist.
Here's what it will look like when your commits are not bananas:
…and here's what it will look like when your commits are bananas:
Ready? Let's get started!
-
Clone this gist
$ git clone https://gist.github.com/bkeepers/546efd41fa08f1af418d5c58e02ec696 bananas
-
Make sure you have a recent version of Node.js installed.
$ node --version v7.8.0
-
package.json
lists the dependencies for our app. Check it out, and then run:$ npm install
-
index.js
is the meat of the app. Read through the code and see if you can make sense of what it's doing. -
Go to smee.io and click Start a new channel. Set
WEBHOOK_PROXY_URL
in your.env
to the URL that you are redirected to. -
Create a new GitHub App with:
- GitHub App name:
yourusername-bananas
, replacingyourusername
with your GitHub username. - Homepage URL and User authorization callback URL: It doesn't matter for this tutorial, so set to
https://github.com/yourusername
, replacingyourusername
with your GitHub username. - Webhook URL: Use your
WEBHOOK_PROXY_URL
from the previous step. - Webhook Secret:
development
- Permissions:
- Commit statuses: Read & Write
- Pull requests: Read-only
- Subscribe to events
- Pull request
- Click Create GitHub App
- GitHub App name:
-
Most importantly, your bot needs an adorable icon. Feel free to use
bananas.jpg
. -
Generate a private key and move it to the project directory.
-
Edit
.env
and setAPP_ID
to the ID of the app you just created, andSUBDOMAIN
to your GitHub username. -
Click the Install button on your app page, and install it on a repository.
-
Go back to your terminal and run
$ npm start
to start the server, which will outputListening on http://localhost:3000
. -
Now go to your repository and create a new file, commit it to a branch, and open a pull request.
Want to learn more: