DEV Community

Cover image for How to add Github Pull Requests as records in an Airtable base
Esther Agbaje
Esther Agbaje

Posted on

How to add Github Pull Requests as records in an Airtable base

Do you ever want to keep track of Pull Requests (PRs) made in your repo in a spreadsheet format? In this tutorial, I'll show you how to set up a workflow to achieve this using Buildable.

With this workflow, whenever a new PR is created in your Github repo, Buildable listens to that event and instantly takes action to add it as a new record in your Airtable database.

Before we jump in, let’s take a look at some prerequisites you'll need for this tutorial:

  • A Buildable account (Create your free account here)
  • A Github Repo
  • An Airtable base

Now, let's get started!

Create a connection

Start by adding a Github Repo connection in your Buildable IDE. Navigate to Connections and then click "New".

From there, select "Github Repos" as your connection source.

Select Connection

Complete the account connection prompt by filling the details:

Complete your connection

Always give your connection an appropriate name e.g "Portfolio-Connection"

Not sure how to get your Github Personal Access Token? See docs

Test your connection and once successful, connect.

Subscribe to events

Next, select the Github repo events you want Buildable to subscribe to. Subscribing to these events allow Buildable to detect when these events occur and carry out the required action.

For this tutorial, we’d want to subscribe to the Pull Request event.

Subscribe to events


Build a workflow

Now that we’ve connected our event source, we need to build out this workflow.

Go to Workflows and select ”New.

New workflow

You'll be prompted to give your workflow a suitable name and description.

Next, attach the pull request event for Buildable to listen to. This is what will trigger our workflow.

To do this, select your Github repo, the connection and then the event. In this case, github-repos > portfolio-connection > pull_request.

Attach event


Add action

The action is what happens when Buildable detects a pull request in our repo. We want that action to send a record to our Airtable database.

From our IDE, click the "Add action" button.

From the list, select Airtable > Create Records


Connect Airtable

If this is the first time you're connecting Airtable to Buildable, then you'll need to fill in the required credentials to connect Airtable to Buildable.

Not sure how to find the API key and Base ID? See below

How to get your Airtable API Key

How to get your Airtable API key

How to get your Airtable Base ID

How to get your Airtable Base ID

You'll notice the "Create Records" node is called createdRecords. Since this is a pull request record, let’s rename this correctly as pullRequestRecord.


Create Airtable base

Now, we need to create the Airtable table where we'll be inserting pull request records. Let's call this table "Pull Requests.".

Next, create the fields you need to record in the table. For the purpose of this tutorial, we'll be creating these 6 fields:

  • Title
  • Description
  • Author
  • Number
  • Created
  • URL


Asides the Number field, make sure the remaining fields are “Single line text” or “Long text” fields.


Modify Input Node

Back in Buildable, you'll notice this template came with pre-filled data. We would need to modify this data for our scenario.

We have our API KEY, BASE ID, and endpoint already pre-filled, so we'd leave them as they are.

Buildable IDE

But, you need to change the tableName to the name of your table in Airtable. Remember, the table is called Pull Request

Finally, map the value of these fields from the Pull Request event to match exactly what we have in Airtable.

$body represents the entire payload coming into your node.

  • Title -> $body.pull_request.title
  • Description -> $body.pull_request.body
  • Author -> $body.sender.login
  • Number -> $body.pull_request.number
  • Date created -> $body.pull_request.created_at
  • URL -> $body.pull_request.url

Buildable field records

For ease, copy and paste this code into your IDE.

const nodeInput = ({ $body, $headers, $env, $data }) => {
  return {
    endpoint: "", // Required
    tableName: "Pull Requests", // Required

    // Required - Array of objects to insert
    records: [
        fields: {
          Title: $body.pull_request.title,
          Description: $body.pull_request.body,
          Author: $body.sender.login,
          Number: $body.pull_request.number,
          Created: $body.pull_request.created_at,
          URL: $body.pull_request.url,
Enter fullscreen mode Exit fullscreen mode

Save and run your connection!


Explore this workflow

Congrats! You've just completed this workflow. Go ahead and trigger a Pull request in your Github repo. You would see this data populated in Airtable 🎉

If you wish to extend the logic of your workflows, add in custom JavaScript functions from Buildable's action library.

Have questions? Drop them in the comments below. Join the Buildable Discord community, or follow on Twitter to learn more about updates.

Latest comments (0)