This commit is contained in:
@@ -1,17 +1,36 @@
|
|||||||
name: AI Chat (Bartender)
|
name: AI Chat (Bartender)
|
||||||
|
|
||||||
|
# WORKFLOW ROUTING:
|
||||||
|
# This workflow handles FREE-FORM questions/chat (no specific command)
|
||||||
|
# Other workflows: ai-issue-triage.yml (@codebot triage), ai-comment-reply.yml (specific commands)
|
||||||
|
# This is the FALLBACK for any @codebot mention that isn't a known command
|
||||||
|
|
||||||
on:
|
on:
|
||||||
issue_comment:
|
issue_comment:
|
||||||
types: [created]
|
types: [created]
|
||||||
|
|
||||||
# CUSTOMIZE YOUR BOT NAME:
|
# CUSTOMIZE YOUR BOT NAME:
|
||||||
# Change '@ai-bot' below to match your config.yml mention_prefix
|
# Change '@codebot' in all conditions below to match your config.yml mention_prefix
|
||||||
# Examples: '@bartender', '@uni', '@joey', '@codebot'
|
# Examples: '@bartender', '@uni', '@joey', '@codebot'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
ai-chat:
|
ai-chat:
|
||||||
# Only run if comment mentions the bot
|
# Only run if comment mentions the bot but NOT a specific command
|
||||||
if: contains(github.event.comment.body, '@codebot') # <-- Change this to your bot name
|
# This prevents duplicate runs with ai-comment-reply.yml and ai-issue-triage.yml
|
||||||
|
# CRITICAL: Ignore bot's own comments to prevent infinite loops (bot username: Bartender)
|
||||||
|
if: |
|
||||||
|
github.event.comment.user.login != 'Bartender' &&
|
||||||
|
contains(github.event.comment.body, '@codebot') &&
|
||||||
|
!contains(github.event.comment.body, '@codebot triage') &&
|
||||||
|
!contains(github.event.comment.body, '@codebot help') &&
|
||||||
|
!contains(github.event.comment.body, '@codebot explain') &&
|
||||||
|
!contains(github.event.comment.body, '@codebot suggest') &&
|
||||||
|
!contains(github.event.comment.body, '@codebot security') &&
|
||||||
|
!contains(github.event.comment.body, '@codebot summarize') &&
|
||||||
|
!contains(github.event.comment.body, '@codebot changelog') &&
|
||||||
|
!contains(github.event.comment.body, '@codebot explain-diff') &&
|
||||||
|
!contains(github.event.comment.body, '@codebot review-again') &&
|
||||||
|
!contains(github.event.comment.body, '@codebot setup-labels')
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|||||||
@@ -1,17 +1,34 @@
|
|||||||
name: AI Comment Reply
|
name: AI Comment Reply
|
||||||
|
|
||||||
|
# WORKFLOW ROUTING:
|
||||||
|
# This workflow handles SPECIFIC commands: help, explain, suggest, security, summarize, changelog, explain-diff, review-again, setup-labels
|
||||||
|
# Other workflows: ai-issue-triage.yml (@codebot triage), ai-chat.yml (free-form questions)
|
||||||
|
|
||||||
on:
|
on:
|
||||||
issue_comment:
|
issue_comment:
|
||||||
types: [created]
|
types: [created]
|
||||||
|
|
||||||
# CUSTOMIZE YOUR BOT NAME:
|
# CUSTOMIZE YOUR BOT NAME:
|
||||||
# Change '@ai-bot' below to match your config.yml mention_prefix
|
# Change '@codebot' in the 'if' condition below to match your config.yml mention_prefix
|
||||||
# Examples: '@bartender', '@uni', '@joey', '@codebot'
|
# Examples: '@bartender', '@uni', '@joey', '@codebot'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
ai-reply:
|
ai-reply:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
if: contains(github.event.comment.body, '@codebot') # <-- Change this to your bot name
|
# Only run for specific commands (not free-form chat or triage)
|
||||||
|
# This prevents duplicate runs with ai-chat.yml and ai-issue-triage.yml
|
||||||
|
# CRITICAL: Ignore bot's own comments to prevent infinite loops (bot username: Bartender)
|
||||||
|
if: |
|
||||||
|
github.event.comment.user.login != 'Bartender' &&
|
||||||
|
(contains(github.event.comment.body, '@codebot help') ||
|
||||||
|
contains(github.event.comment.body, '@codebot explain') ||
|
||||||
|
contains(github.event.comment.body, '@codebot suggest') ||
|
||||||
|
contains(github.event.comment.body, '@codebot security') ||
|
||||||
|
contains(github.event.comment.body, '@codebot summarize') ||
|
||||||
|
contains(github.event.comment.body, '@codebot changelog') ||
|
||||||
|
contains(github.event.comment.body, '@codebot explain-diff') ||
|
||||||
|
contains(github.event.comment.body, '@codebot review-again') ||
|
||||||
|
contains(github.event.comment.body, '@codebot setup-labels'))
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
@@ -30,12 +47,52 @@ jobs:
|
|||||||
- name: Run AI Comment Response
|
- name: Run AI Comment Response
|
||||||
env:
|
env:
|
||||||
AI_REVIEW_TOKEN: ${{ secrets.AI_REVIEW_TOKEN }}
|
AI_REVIEW_TOKEN: ${{ secrets.AI_REVIEW_TOKEN }}
|
||||||
AI_REVIEW_REPO: ${{ gitea.repository }}
|
|
||||||
AI_REVIEW_API_URL: https://git.hiddenden.cafe/api/v1
|
AI_REVIEW_API_URL: https://git.hiddenden.cafe/api/v1
|
||||||
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
||||||
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
|
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
|
||||||
OLLAMA_HOST: ${{ secrets.OLLAMA_HOST }}
|
OLLAMA_HOST: ${{ secrets.OLLAMA_HOST }}
|
||||||
run: |
|
run: |
|
||||||
cd .ai-review/tools/ai-review
|
cd .ai-review/tools/ai-review
|
||||||
python main.py comment ${{ gitea.repository }} ${{ gitea.event.issue.number }} \
|
|
||||||
"${{ gitea.event.comment.body }}"
|
# 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
|
||||||
|
|||||||
@@ -1,12 +1,21 @@
|
|||||||
name: AI Issue Triage
|
name: AI Issue Triage
|
||||||
|
|
||||||
|
# WORKFLOW ROUTING:
|
||||||
|
# This workflow handles ONLY the 'triage' command
|
||||||
|
# Other workflows: ai-comment-reply.yml (specific commands), ai-chat.yml (free-form questions)
|
||||||
|
|
||||||
on:
|
on:
|
||||||
issues:
|
issue_comment:
|
||||||
types: [opened, labeled]
|
types: [created]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
ai-triage:
|
ai-triage:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
# Only run if comment contains @codebot triage
|
||||||
|
# CRITICAL: Ignore bot's own comments to prevent infinite loops (bot username: Bartender)
|
||||||
|
if: |
|
||||||
|
github.event.comment.user.login != 'Bartender' &&
|
||||||
|
contains(github.event.comment.body, '@codebot triage')
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
@@ -32,5 +41,4 @@ jobs:
|
|||||||
OLLAMA_HOST: ${{ secrets.OLLAMA_HOST }}
|
OLLAMA_HOST: ${{ secrets.OLLAMA_HOST }}
|
||||||
run: |
|
run: |
|
||||||
cd .ai-review/tools/ai-review
|
cd .ai-review/tools/ai-review
|
||||||
python main.py issue ${{ gitea.repository }} ${{ gitea.event.issue.number }} \
|
python main.py issue ${{ gitea.repository }} ${{ gitea.event.issue.number }}
|
||||||
--title "${{ gitea.event.issue.title }}"
|
|
||||||
|
|||||||
Reference in New Issue
Block a user