forked from gqy20/IssueLab
-
Notifications
You must be signed in to change notification settings - Fork 0
119 lines (106 loc) · 4.27 KB
/
agent.yml
File metadata and controls
119 lines (106 loc) · 4.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
name: Run Agent on Dispatch
on:
workflow_dispatch:
inputs:
agent:
description: 'Agent name to run'
required: true
type: string
issue_number:
description: 'Issue number to analyze'
required: true
type: string
repository_dispatch:
types: [agent_trigger]
permissions:
contents: read
issues: write
jobs:
run-agent:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v7
with:
python-version: '3.13'
enable-cache: true
- run: uv sync
- name: Get agent name
id: agent
run: |
# workflow_dispatch: 使用输入的agent名称
# repository_dispatch: 从仓库名提取(如 gqy22/IssueLab -> gqy22)
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
agent="${{ inputs.agent }}"
else
agent="${GITHUB_REPOSITORY%/*}"
fi
echo "name=$agent" >> $GITHUB_OUTPUT
echo "🤖 Agent: $agent"
- name: Prepare MCP env for agent
env:
ISSUELAB_MCP_ENV_JSON: ${{ secrets.ISSUELAB_MCP_ENV_JSON }}
PAT_TOKEN: ${{ secrets.PAT_TOKEN || secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN || secrets.GITHUB_TOKEN }}
ZOTERO_API_KEY: ${{ secrets.ZOTERO_API_KEY }}
ZOTERO_LIBRARY_ID: ${{ secrets.ZOTERO_LIBRARY_ID }}
TAVILY_API_KEY: ${{ secrets.TAVILY_API_KEY }}
SERPAPI_API_KEY: ${{ secrets.SERPAPI_API_KEY }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
run: |
uv run python scripts/prepare_mcp_env.py \
--agent "${{ steps.agent.outputs.name }}" \
--include-root-mcp \
--write-github-env
- name: Run agent
run: |
# 获取参数:workflow_dispatch 或 repository_dispatch
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
ISSUE_NUMBER="${{ inputs.issue_number }}"
SOURCE_REPO="${{ github.repository }}"
else
ISSUE_NUMBER="${{ github.event.client_payload.issue_number }}"
SOURCE_REPO="${{ github.event.client_payload.source_repo }}"
fi
echo "🚀 执行 agent: ${{ steps.agent.outputs.name }}"
echo "📝 Source repo: $SOURCE_REPO"
echo "📝 Issue: $ISSUE_NUMBER"
mkdir -p ${{ github.workspace }}/logs
# 执行 agent
GH_REPO="$SOURCE_REPO" uv run python -m issuelab execute \
--issue "$ISSUE_NUMBER" \
--agents "${{ steps.agent.outputs.name }}" \
--post
env:
GH_TOKEN: ${{ secrets.PAT_TOKEN || secrets.GITHUB_TOKEN }}
ANTHROPIC_AUTH_TOKEN: ${{ secrets.ANTHROPIC_AUTH_TOKEN }}
ANTHROPIC_BASE_URL: ${{ secrets.ANTHROPIC_BASE_URL || 'https://api.minimaxi.com/anthropic' }}
ANTHROPIC_MODEL: ${{ secrets.ANTHROPIC_MODEL || 'MiniMax-M2.1' }}
LOG_FILE: ${{ github.workspace }}/logs/agent_${{ github.event.client_payload.issue_number }}.log
LOG_LEVEL: DEBUG
CLAUDE_AGENT_SDK_SKIP_VERSION_CHECK: "true"
CLAUDE_CODE_STREAM_CLOSE_TIMEOUT: "30000"
ACTIONS_STEP_DEBUG: "true"
ACTIONS_RUNNER_DEBUG: "true"
MCP_LOG_DETAIL: "1"
PROMPT_LOG: "1"
- uses: actions/upload-artifact@v4
with:
name: agent-logs-${{ github.event.client_payload.issue_number }}
path: logs/
retention-days: 7
- name: Comment on failure
if: failure()
run: |
# 获取参数
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
ISSUE_NUMBER="${{ inputs.issue_number }}"
SOURCE_REPO="${{ github.repository }}"
else
ISSUE_NUMBER="${{ github.event.client_payload.issue_number }}"
SOURCE_REPO="${{ github.event.client_payload.source_repo }}"
fi
GH_REPO="$SOURCE_REPO" gh issue comment "$ISSUE_NUMBER" \
--body "❌ Agent ${{ steps.agent.outputs.name }} execution failed. Check [workflow logs](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) for details."
env:
GH_TOKEN: ${{ secrets.PAT_TOKEN || secrets.GITHUB_TOKEN }}