All checks were successful
Enterprise AI Code Review / ai-review (pull_request) Successful in 26s
82 lines
3.1 KiB
YAML
82 lines
3.1 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_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 }}
|
|
run: |
|
|
cd .ai-review/tools/ai-review
|
|
|
|
# Determine if this is a PR or issue comment
|
|
IS_PR="${{ gitea.event.issue.pull_request != null }}"
|
|
REPO="${{ gitea.repository }}"
|
|
ISSUE_NUMBER="${{ gitea.event.issue.number }}"
|
|
|
|
# Validate inputs
|
|
if [ -z "$REPO" ] || [ -z "$ISSUE_NUMBER" ]; then
|
|
echo "Error: Missing required parameters"
|
|
exit 1
|
|
fi
|
|
|
|
# Validate repository format (owner/repo)
|
|
if ! echo "$REPO" | grep -qE '^[a-zA-Z0-9_-]+/[a-zA-Z0-9_-]+$'; then
|
|
echo "Error: Invalid repository format: $REPO"
|
|
exit 1
|
|
fi
|
|
|
|
if [ "$IS_PR" = "true" ]; then
|
|
# This is a PR comment - use safe dispatch with minimal event data
|
|
# Build minimal event payload (does not include sensitive user data)
|
|
EVENT_DATA=$(cat <<EOF
|
|
{
|
|
"action": "created",
|
|
"issue": {
|
|
"number": ${{ gitea.event.issue.number }},
|
|
"pull_request": {}
|
|
},
|
|
"comment": {
|
|
"id": ${{ gitea.event.comment.id }},
|
|
"body": $(echo '${{ gitea.event.comment.body }}' | jq -Rs .)
|
|
}
|
|
}
|
|
EOF
|
|
)
|
|
|
|
# Use safe dispatch utility
|
|
python utils/safe_dispatch.py issue_comment "$REPO" "$EVENT_DATA"
|
|
else
|
|
# This is an issue comment - use the comment command
|
|
COMMENT_BODY='${{ gitea.event.comment.body }}'
|
|
python main.py comment "$REPO" "$ISSUE_NUMBER" "$COMMENT_BODY"
|
|
fi
|