Back to Iii

GitHub Integration

frameworks/motia/docs/content/docs/examples/github-integration-workflow.mdx

0.13.03.7 KB
Original Source

Workflow Overview

<div className="my-8">![GitHub Issue Workflow](./../img/github-issue-workflow.png)</div>

Try it yourself:


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

<Folder name="steps" defaultOpen> <Folder name="issue-triage" defaultOpen> <File name="github-webhook.step.ts" /> <File name="issue-classifier.step.ts" /> <File name="label-assigner.step.ts" /> <File name="assignee-selector.step.ts" /> <File name="handle-new-issue.step.ts" /> <File name="handle-issue-update.step.ts" /> <File name="handle-issue-closure.step.ts" /> </Folder> <Folder name="pr-classifier" defaultOpen> <File name="pr-webhook.step.ts" /> <File name="pr-classifier.step.ts" /> <File name="pr-label-assigner.step.ts" /> <File name="pr-reviewer-assigner.step.ts" /> <File name="pr-test-monitor.step.ts" /> </Folder> </Folder> <Callout type="info"> This example uses the `steps/` directory, but you can also use `src/` or both. Motia discovers step files from either location automatically. </Callout>

See the full source code on GitHub.

Visual Overview

Here's how the automation flow works:

<div className="my-8">![Flow: GitHub Issue Workflow](../img/github-issue-workflow.png)</div> <div className="my-8">![Flow: GitHub PR Workflow](../img/github-pr-workflow.png)</div>
  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

<Steps>

Prerequisites

Make sure you have:

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

Clone the Repository

bash
git clone [email protected]:MotiaDev/motia-examples.git
cd examples/github-integration-workflow

Install Dependencies

bash
npm install

Configure Environment Variables

Create a .env file by copying the example:

bash
cp .env.example .env

Update your .env with the following credentials:

bash
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

bash
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
</Steps> <Callout type="info"> For more detailed setup instructions and configuration options, check out the [full documentation](https://github.com/MotiaDev/motia-examples/tree/main/examples/integrations/github/github-integration-workflow). </Callout>