All checks were successful
Enterprise AI Code Review / ai-review (pull_request) Successful in 25s
- Replace inline toJSON() with environment variables - Use Python to parse JSON and dispatch events properly - Avoid bash syntax errors with parentheses in JSON - Maintain same functionality for PR vs issue comment handling Fixes: /var/run/act/workflow/4: line 25: syntax error near unexpected token
86 lines
3.2 KiB
YAML
86 lines
3.2 KiB
YAML
name: AI Comment Reply
|
|
|
|
on:
|
|
issue_comment:
|
|
types: [created]
|
|
|
|
# CUSTOMIZE YOUR BOT NAME:
|
|
# Change '@ai-bot' below to match your config.yml mention_prefix
|
|
# Examples: '@bartender', '@uni', '@joey', '@codebot'
|
|
|
|
jobs:
|
|
ai-reply:
|
|
runs-on: ubuntu-latest
|
|
if: contains(github.event.comment.body, '@codebot') # <-- Change this to your bot name
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
repository: Hiddenden/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://git.hiddenden.cafe/api/v1
|
|
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
|
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
|
|
OLLAMA_HOST: ${{ secrets.OLLAMA_HOST }}
|
|
EVENT_ISSUE_JSON: ${{ toJSON(gitea.event.issue) }}
|
|
EVENT_COMMENT_JSON: ${{ toJSON(gitea.event.comment) }}
|
|
IS_PR: ${{ gitea.event.issue.pull_request != null }}
|
|
ISSUE_NUMBER: ${{ gitea.event.issue.number }}
|
|
COMMENT_BODY: ${{ gitea.event.comment.body }}
|
|
run: |
|
|
cd .ai-review/tools/ai-review
|
|
|
|
# Check if this is a PR or an issue
|
|
if [ "$IS_PR" = "true" ]; then
|
|
# This is a PR comment - dispatch as issue_comment event
|
|
# Create JSON payload using environment variables
|
|
python -c "
|
|
import os
|
|
import json
|
|
import sys
|
|
|
|
issue = json.loads(os.environ['EVENT_ISSUE_JSON'])
|
|
comment = json.loads(os.environ['EVENT_COMMENT_JSON'])
|
|
event_data = {
|
|
'action': 'created',
|
|
'issue': issue,
|
|
'comment': comment
|
|
}
|
|
|
|
# Import and run dispatcher
|
|
sys.path.insert(0, '.')
|
|
from dispatcher import get_dispatcher
|
|
from agents.pr_agent import PRAgent
|
|
from agents.issue_agent import IssueAgent
|
|
|
|
dispatcher = get_dispatcher()
|
|
dispatcher.register_agent(PRAgent())
|
|
dispatcher.register_agent(IssueAgent())
|
|
|
|
repo = os.environ['AI_REVIEW_REPO']
|
|
owner, repo_name = repo.split('/')
|
|
|
|
result = dispatcher.dispatch('issue_comment', event_data, owner, repo_name)
|
|
|
|
if result.errors:
|
|
print(f'Errors: {result.errors}')
|
|
sys.exit(1)
|
|
"
|
|
else
|
|
# This is an issue comment - use the comment command
|
|
python main.py comment "$AI_REVIEW_REPO" "$ISSUE_NUMBER" "$COMMENT_BODY"
|
|
fi
|