fix: Resolve workflow syntax error in ai-comment-reply.yml
All checks were successful
Enterprise AI Code Review / ai-review (pull_request) Successful in 25s
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
This commit is contained in:
@@ -35,16 +35,51 @@ jobs:
|
|||||||
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 }}
|
||||||
|
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: |
|
run: |
|
||||||
cd .ai-review/tools/ai-review
|
cd .ai-review/tools/ai-review
|
||||||
|
|
||||||
# Check if this is a PR or an issue
|
# Check if this is a PR or an issue
|
||||||
if [ "${{ gitea.event.issue.pull_request }}" != "" ]; then
|
if [ "$IS_PR" = "true" ]; then
|
||||||
# This is a PR comment - dispatch as issue_comment event
|
# This is a PR comment - dispatch as issue_comment event
|
||||||
python main.py dispatch ${{ gitea.repository }} issue_comment \
|
# Create JSON payload using environment variables
|
||||||
'{"action":"created","issue":${{ toJSON(gitea.event.issue) }},"comment":${{ toJSON(gitea.event.comment) }}}'
|
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
|
else
|
||||||
# This is an issue comment - use the comment command
|
# This is an issue comment - use the comment command
|
||||||
python main.py comment ${{ gitea.repository }} ${{ gitea.event.issue.number }} \
|
python main.py comment "$AI_REVIEW_REPO" "$ISSUE_NUMBER" "$COMMENT_BODY"
|
||||||
"${{ gitea.event.comment.body }}"
|
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user