Files
openrabbit/docs/workflows.md
Latte ca3e124745 revert 18fb6c890e
revert Update AI_REVIEW_API_URL to new OpenRabbit path
2025-12-21 13:28:34 +00:00

9.6 KiB

Workflows

This document provides ready-to-use workflow files for integrating AI code review into your repositories. Workflows are provided for both GitHub Actions and Gitea Actions.


Platform Comparison

Feature GitHub Gitea
Context variable github.* gitea.*
Default token GITHUB_TOKEN AI_REVIEW_TOKEN (custom)
API URL https://api.github.com Your Gitea instance URL
Tools location Same repo (tools/ai-review) Checkout from central repo

GitHub Workflows

PR Review Workflow

# .github/workflows/ai-review.yml
name: AI Code Review

on:
  pull_request:
    types: [opened, synchronize]

jobs:
  ai-review:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - uses: actions/setup-python@v5
        with:
          python-version: "3.11"

      - run: pip install requests pyyaml

      - name: Run AI Review
        env:
          AI_REVIEW_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          AI_REVIEW_REPO: ${{ github.repository }}
          AI_REVIEW_API_URL: https://api.github.com
          OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
        run: |
          cd tools/ai-review
          python main.py pr ${{ github.repository }} ${{ github.event.pull_request.number }}

Issue Triage Workflow

# .github/workflows/ai-issue-triage.yml
name: AI Issue Triage

on:
  issues:
    types: [opened, labeled]

jobs:
  ai-triage:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - uses: actions/setup-python@v5
        with:
          python-version: "3.11"

      - run: pip install requests pyyaml

      - name: Run AI Issue Triage
        env:
          AI_REVIEW_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          AI_REVIEW_REPO: ${{ github.repository }}
          AI_REVIEW_API_URL: https://api.github.com
          OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
        run: |
          cd tools/ai-review
          python main.py issue ${{ github.repository }} ${{ github.event.issue.number }} \
            --title "${{ github.event.issue.title }}"

Comment Reply Workflow (includes Bartender Chat)

# .github/workflows/ai-comment-reply.yml
name: AI Comment Reply

on:
  issue_comment:
    types: [created]

jobs:
  ai-reply:
    runs-on: ubuntu-latest
    if: contains(github.event.comment.body, '@ai-bot')
    steps:
      - uses: actions/checkout@v4

      - uses: actions/setup-python@v5
        with:
          python-version: "3.11"

      - run: pip install requests pyyaml

      - name: Run AI Comment Response
        env:
          AI_REVIEW_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          AI_REVIEW_REPO: ${{ github.repository }}
          AI_REVIEW_API_URL: https://api.github.com
          OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
          SEARXNG_URL: ${{ secrets.SEARXNG_URL }}
        run: |
          cd tools/ai-review
          python main.py comment ${{ github.repository }} ${{ github.event.issue.number }} \
            "${{ github.event.comment.body }}"

Codebase Analysis Workflow

# .github/workflows/ai-codebase-review.yml
name: AI Codebase Analysis

on:
  schedule:
    - cron: "0 0 * * 0"  # Weekly on Sunday
  workflow_dispatch:      # Manual trigger

jobs:
  ai-codebase:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - uses: actions/setup-python@v5
        with:
          python-version: "3.11"

      - run: pip install requests pyyaml

      - name: Run Codebase Analysis
        env:
          AI_REVIEW_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          AI_REVIEW_REPO: ${{ github.repository }}
          AI_REVIEW_API_URL: https://api.github.com
          OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
        run: |
          cd tools/ai-review
          python main.py codebase ${{ github.repository }}

Gitea Workflows

PR Review Workflow

# .gitea/workflows/enterprise-ai-review.yml
name: AI Code Review

on:
  pull_request:
    types: [opened, synchronize]

jobs:
  ai-review:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - uses: actions/checkout@v4
        with:
          repository: YourOrg/OpenRabbit
          path: .ai-review
          token: ${{ secrets.AI_REVIEW_TOKEN }}

      - uses: actions/setup-python@v5
        with:
          python-version: "3.11"

      - run: pip install requests pyyaml

      - name: Run AI Review
        env:
          AI_REVIEW_TOKEN: ${{ secrets.AI_REVIEW_TOKEN }}
          AI_REVIEW_REPO: ${{ gitea.repository }}
          AI_REVIEW_API_URL: https://your-gitea.example.com/api/v1
          OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
        run: |
          cd .ai-review/tools/ai-review
          python main.py pr ${{ gitea.repository }} ${{ gitea.event.pull_request.number }}

Issue Triage Workflow

# .gitea/workflows/ai-issue-triage.yml
name: AI Issue Triage

on:
  issues:
    types: [opened, labeled]

jobs:
  ai-triage:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - uses: actions/checkout@v4
        with:
          repository: YourOrg/OpenRabbit
          path: .ai-review
          token: ${{ secrets.AI_REVIEW_TOKEN }}

      - uses: actions/setup-python@v5
        with:
          python-version: "3.11"

      - run: pip install requests pyyaml

      - name: Run AI Issue Triage
        env:
          AI_REVIEW_TOKEN: ${{ secrets.AI_REVIEW_TOKEN }}
          AI_REVIEW_REPO: ${{ gitea.repository }}
          AI_REVIEW_API_URL: https://your-gitea.example.com/api/v1
          OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
        run: |
          cd .ai-review/tools/ai-review
          python main.py issue ${{ gitea.repository }} ${{ gitea.event.issue.number }} \
            --title "${{ gitea.event.issue.title }}"

Comment Reply Workflow (includes Bartender Chat)

# .gitea/workflows/ai-comment-reply.yml
name: AI Comment Reply

on:
  issue_comment:
    types: [created]

jobs:
  ai-reply:
    runs-on: ubuntu-latest
    if: contains(github.event.comment.body, '@ai-bot')
    steps:
      - uses: actions/checkout@v4

      - uses: actions/checkout@v4
        with:
          repository: YourOrg/OpenRabbit
          path: .ai-review
          token: ${{ secrets.AI_REVIEW_TOKEN }}

      - uses: actions/setup-python@v5
        with:
          python-version: "3.11"

      - run: pip install requests pyyaml

      - name: Run AI Comment Response
        env:
          AI_REVIEW_TOKEN: ${{ secrets.AI_REVIEW_TOKEN }}
          AI_REVIEW_REPO: ${{ gitea.repository }}
          AI_REVIEW_API_URL: https://your-gitea.example.com/api/v1
          OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
          SEARXNG_URL: ${{ secrets.SEARXNG_URL }}
        run: |
          cd .ai-review/tools/ai-review
          python main.py comment ${{ gitea.repository }} ${{ gitea.event.issue.number }} \
            "${{ gitea.event.comment.body }}"

Codebase Analysis Workflow

# .gitea/workflows/ai-codebase-review.yml
name: AI Codebase Analysis

on:
  schedule:
    - cron: "0 0 * * 0"  # Weekly on Sunday
  workflow_dispatch:      # Manual trigger

jobs:
  ai-codebase:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - uses: actions/checkout@v4
        with:
          repository: YourOrg/OpenRabbit
          path: .ai-review
          token: ${{ secrets.AI_REVIEW_TOKEN }}

      - uses: actions/setup-python@v5
        with:
          python-version: "3.11"

      - run: pip install requests pyyaml

      - name: Run Codebase Analysis
        env:
          AI_REVIEW_TOKEN: ${{ secrets.AI_REVIEW_TOKEN }}
          AI_REVIEW_REPO: ${{ gitea.repository }}
          AI_REVIEW_API_URL: https://your-gitea.example.com/api/v1
          OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
        run: |
          cd .ai-review/tools/ai-review
          python main.py codebase ${{ gitea.repository }}

Required Secrets

GitHub

Secret Required Description
GITHUB_TOKEN Auto Built-in token (automatic)
OPENAI_API_KEY Choose one OpenAI API key
OPENROUTER_API_KEY Choose one OpenRouter API key
OLLAMA_HOST Choose one Ollama server URL
SEARXNG_URL Optional SearXNG instance for web search

Gitea

Secret Required Description
AI_REVIEW_TOKEN Yes Gitea bot access token
OPENAI_API_KEY Choose one OpenAI API key
OPENROUTER_API_KEY Choose one OpenRouter API key
OLLAMA_HOST Choose one Ollama server URL
SEARXNG_URL Optional SearXNG instance for web search

Customization

For GitHub

The tools are included in the same repository under tools/ai-review, so no additional checkout is needed.

For Gitea

Replace the repository reference with your OpenRabbit fork:

repository: YourOrg/OpenRabbit

Replace the API URL with your Gitea instance:

AI_REVIEW_API_URL: https://your-gitea.example.com/api/v1

Chat/Bartender Workflow

Both platforms support the Bartender chat agent through the comment reply workflow. When @ai-bot is mentioned with a question (not a specific command like summarize), the Chat Agent handles it with tool calling capabilities.

To enable web search, set the SEARXNG_URL secret to your SearXNG instance URL.

Example usage:

@ai-bot How do I configure rate limiting?
@ai-bot Find all authentication-related files
@ai-bot What does the dispatcher module do?