Skip to content

An example Babashka Script authenticating as a Github App and interacting with the Checks API

Notifications You must be signed in to change notification settings

brandonstubbs/bb-github-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

Babashka Github Application

This is an example babashka script that can authenticate as a Github application. To demo this, the application interacts with the Github Checks API. As the main focus of this is for the authentication and interaction with the Checks API we are not plugging on a complete webhook demo, you could use what you have learned from here and follow the official Github tutorial

These runs were created using this demo.

Prerequisites

You will need two things:
A repository and a commit on that repository which we will create the check runs on.
A Github Application and private key to use for authentication.

Github Application Setup

Create Application

To create a Github Application you need to do the following:

  • In your Github Settings, navigate to: Developer settings -> Github Apps.
  • Click "New Github App"
    • Choose a unique Github App name. For this example I am using bb checks
    • Homepage URL. Link to your application webpage. For this example I am using https://babashka.org/
    • Webhook -> active. Disable this, not in scope for this demo.
    • Repository Permissions -> Enable Read and write for Checks.
    • Click "Create GitHub App"
    • Take note of the App ID under the about section, you will need to copy this into the code.

Generate Application Private Key

To create a Github Application private key, you will need to do the following:

  • In your Github Settings, navigate to: Developer settings -> Github Apps.
  • Click "Edit" next to the Github app your are using for this.
  • Scroll down to "Private keys"
  • click "Generate"
  • Take note of this downloaded pem, you will need to copy the location of this into the code.

Install Github app to your account

You have created a Github application that can be used by other accounts, now you just need to install it into yours.

  • In your Github Settings, navigate to: Developer settings -> Github Apps.
  • Click "Edit" next to the Github app your are using for this.
  • Click "Public page" in the sidebar.
  • Click "Install".

Run Example

Statup a Babashka REPL! Open github_app.clj and navigate to the Rich Comment Block. Change the variables under "change these" and step through the examples.

About

An example Babashka Script authenticating as a Github App and interacting with the Checks API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published