Motia Icon

GitHub Integration Workflow

Build an automated GitHub issue and PR management system with AI-powered classification and routing

Live Example

Try out the code directly in your browser:

Let's build a GitHub automation system that:

  1. Automatically triages and classifies new issues
  2. Intelligently assigns labels based on content
  3. Suggests appropriate assignees and reviewers
  4. Monitors PR test status
  5. Generates contextual comments

Workflow Structure

The GitHub integration workflow is organized into two main components:

  • Issue Triage: Handles the management of GitHub issues
  • PR Classifier: Manages pull request workflows

The Steps

github-webhook.step.ts
issue-classifier.step.ts
label-assigner.step.ts
assignee-selector.step.ts
handle-new-issue.step.ts
handle-issue-update.step.ts
handle-issue-closure.step.ts
pr-webhook.step.ts
pr-classifier.step.ts
pr-label-assigner.step.ts
pr-reviewer-assigner.step.ts
pr-test-monitor.step.ts

Visual Overview

Here's how the automation flow works:

Flow: GitHub Issue Workflow
Flow: GitHub PR Workflow
  1. Webhook Reception → Captures GitHub events
  2. Issue/PR Classification → Analyzes content with AI
  3. Automated Labeling → Applies appropriate labels
  4. Smart Assignment → Suggests reviewers and assignees
  5. Status Monitoring → Tracks PR test status

Try It Out

Prerequisites

Make sure you have:

  • GitHub account with personal access token
  • Node.js installed
  • OpenAI API key (for AI classification)

Clone the Repository

git clone git@github.com:MotiaDev/motia-examples.git
cd examples/github-integration-workflow

Install Dependencies

npm install

Configure Environment Variables

Create a .env file by copying the example:

cp .env.example .env

Update your .env with the following credentials:

GITHUB_TOKEN=your_github_token_here
OPENAI_API_KEY=your_openai_api_key

Set Up GitHub Webhook

  1. Go to your GitHub repository settings
  2. Navigate to Webhooks and add a new webhook
  3. Set the Payload URL to your Motia server endpoint
  4. Select content type as application/json
  5. Choose which events to trigger the webhook (Issues, Pull requests)
  6. Save the webhook

Run the Application

npm run dev

Test the Flow

  1. Create a new issue in your GitHub repository
  2. Watch as it gets automatically classified and labeled
  3. Create a new PR to see the reviewer assignment in action
  4. Check the PR comments for test status updates

For more detailed setup instructions and configuration options, check out the full documentation.

Need help? See our Community Resources for questions, examples, and discussions.

On this page