-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathaction.yml
More file actions
220 lines (209 loc) · 9 KB
/
Copy pathaction.yml
File metadata and controls
220 lines (209 loc) · 9 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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
name: AI Issue Analysis
description: Analyze a GitHub issue with an AI coding agent (Copilot / Claude / Codex) and keep a comment updated with progress and the final result.
author: MistEO
inputs:
agent:
description: AI agent to use. One of copilot, claude, codex.
required: true
api-key:
description: API key or token for the agent. Supports multiple keys (one per line); a random one is picked each run.
required: true
api-base-url:
description: Custom API base URL. Typically passed from a repository secret (e.g. secrets.API_BASE_URL).
required: false
default: ""
model:
description: Model name passed to the agent CLI.
required: false
default: ""
agent-package:
description: NPM package to install. Leave empty to use the agent default.
required: false
default: ""
agent-extra-args:
description: Extra CLI arguments appended to the agent command (e.g. "--reasoning-effort xhigh" for Copilot).
required: false
default: ""
issue-number:
description: Issue number to analyze. If empty, inferred from the event payload.
required: false
default: ""
github-token:
description: GitHub token used to create and update issue comments.
required: true
bot-name:
description: Bot mention to strip from issue_comment messages.
required: false
default: ""
initial-comment-body:
description: Initial comment body shown before analysis finishes.
required: false
default: |
🤖 **AI 正在分析该 Issue...**
感谢您的反馈!AI 正在自动分析该问题,预计耗时约 10 分钟。
action-link-text:
description: Link text for the current GitHub Actions run.
required: false
default: GitHub Action 运行记录
details-summary:
description: Summary text for the collapsible streaming output block.
required: false
default: 点击此处展开分析过程
prompt-template:
description: "Base prompt template. Placeholders: {{issue_number}}, {{answer_file}}, {{repository}}, {{event_name}}."
required: false
default: 分析 GitHub Issue {{issue_number}}。把最终结论写到 {{answer_file}}。
comment-prompt-template:
description: "Extra prompt appended when the comment has content. Additional placeholder: {{comment_body}}."
required: false
default: 补充要求:{{comment_body}}
stream-update-interval-seconds:
description: Seconds between streamed comment updates.
required: false
default: "30"
cache-dir:
description: Directory for temporary files.
required: false
default: .cache
answer-file:
description: File path where the agent writes the final answer.
required: false
default: answer.md
checkout-repository:
description: Whether to run actions/checkout inside the action.
required: false
default: "true"
process-error-message:
description: Fallback message in the analysis log when the answer file is missing.
required: false
default: 分析过程出现错误,请重试。
result-error-message:
description: Fallback message in the final comment when the answer file is missing.
required: false
default: 分析结果出现错误,请重试。
extra-comment-content:
description: Extra content appended to every comment update.
required: false
default: ""
outputs:
issue-number:
description: Resolved issue number.
value: ${{ steps.prepare.outputs.issue_number }}
comment-id:
description: Issue comment ID.
value: ${{ steps.initial_comment.outputs.comment-id }}
comment-url:
description: Issue comment URL.
value: ${{ steps.finalize.outputs.comment-url }}
analysis-prompt:
description: Final prompt sent to the agent.
value: ${{ steps.finalize.outputs.analysis-prompt }}
agent-output:
description: Full execution log.
value: ${{ steps.finalize.outputs.agent-output }}
final-conclusion:
description: Final conclusion from the agent.
value: ${{ steps.finalize.outputs.final-conclusion }}
runs:
using: composite
steps:
- name: Checkout repository
if: ${{ inputs.checkout-repository == 'true' }}
uses: actions/checkout@v4
- name: Prepare (issue number, prompt, runtime paths)
id: prepare
shell: bash
env:
INPUT_ISSUE_NUMBER: ${{ inputs.issue-number }}
EVENT_NAME: ${{ github.event_name }}
BOT_NAME: ${{ inputs.bot-name }}
ANSWER_FILE: ${{ inputs.answer-file }}
PROMPT_TEMPLATE: ${{ inputs.prompt-template }}
COMMENT_PROMPT_TEMPLATE: ${{ inputs.comment-prompt-template }}
REPOSITORY: ${{ github.repository }}
CACHE_DIR: ${{ inputs.cache-dir }}
DETAILS_SUMMARY: ${{ inputs.details-summary }}
ACTION_LINK_TEXT: ${{ inputs.action-link-text }}
GITHUB_SERVER_URL: ${{ github.server_url }}
GITHUB_RUN_ID: ${{ github.run_id }}
run: python "${{ github.action_path }}/scripts/prepare.py"
- name: Create initial comment
id: initial_comment
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ steps.prepare.outputs.issue_number }}
token: ${{ inputs.github-token }}
body: |
${{ inputs.initial-comment-body }}
---
${{ steps.prepare.outputs.action_link }}
- name: Run agent analysis with streaming updates
shell: bash
env:
AGENT_NAME: ${{ inputs.agent }}
API_KEY: ${{ inputs.api-key }}
API_BASE_URL: ${{ inputs.api-base-url }}
MODEL: ${{ inputs.model }}
AGENT_PACKAGE: ${{ inputs.agent-package }}
AGENT_EXTRA_ARGS: ${{ inputs.agent-extra-args }}
COMMENT_GITHUB_TOKEN: ${{ inputs.github-token }}
REPO: ${{ github.repository }}
COMMENT_ID: ${{ steps.initial_comment.outputs.comment-id }}
ISSUE_NUMBER: ${{ steps.prepare.outputs.issue_number }}
GITHUB_SERVER_URL: ${{ github.server_url }}
ANALYSIS_PROMPT_FILE: ${{ steps.prepare.outputs.analysis_prompt_file }}
OUTPUT_FILE: ${{ steps.prepare.outputs.agent_output_file }}
EXECUTION_LOG_FILE: ${{ steps.prepare.outputs.agent_execution_log_file }}
BODY_FILE: ${{ steps.prepare.outputs.comment_body_file }}
INITIAL_BODY: ${{ inputs.initial-comment-body }}
ACTION_LINK: ${{ steps.prepare.outputs.action_link }}
DETAILS_BEGIN: ${{ steps.prepare.outputs.details_begin }}
DETAILS_END: ${{ steps.prepare.outputs.details_end }}
STREAM_UPDATE_INTERVAL: ${{ inputs.stream-update-interval-seconds }}
EXTRA_COMMENT_CONTENT: ${{ inputs.extra-comment-content }}
run: python "${{ github.action_path }}/scripts/run_agent.py"
- name: Finalize (comment, artifacts, outputs)
id: finalize
if: ${{ always() }}
shell: bash
env:
COMMENT_ID: ${{ steps.initial_comment.outputs.comment-id }}
GITHUB_SERVER_URL: ${{ github.server_url }}
ISSUE_NUMBER: ${{ steps.prepare.outputs.issue_number }}
REPOSITORY: ${{ github.repository }}
ANALYSIS_PROMPT_FILE: ${{ steps.prepare.outputs.analysis_prompt_file }}
EXECUTION_LOG_FILE: ${{ steps.prepare.outputs.agent_execution_log_file }}
OUTPUT_ARTIFACT_FILE: ${{ steps.prepare.outputs.agent_output_artifact_file }}
OUTPUT_FILE: ${{ steps.prepare.outputs.agent_output_file }}
ANSWER_FILE: ${{ inputs.answer-file }}
CONCLUSION_ARTIFACT_FILE: ${{ steps.prepare.outputs.final_conclusion_artifact_file }}
FINAL_COMMENT_FILE: ${{ steps.prepare.outputs.final_comment_file }}
ACTION_LINK: ${{ steps.prepare.outputs.action_link }}
DETAILS_BEGIN: ${{ steps.prepare.outputs.details_begin }}
DETAILS_END: ${{ steps.prepare.outputs.details_end }}
EXTRA_COMMENT_CONTENT: ${{ inputs.extra-comment-content }}
RESULT_ERROR_MESSAGE: ${{ inputs.result-error-message }}
PROCESS_ERROR_MESSAGE: ${{ inputs.process-error-message }}
run: python "${{ github.action_path }}/scripts/finalize.py"
- name: Upload agent output artifact
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: agent-output-issue-${{ steps.prepare.outputs.issue_number }}-comment-${{ steps.initial_comment.outputs.comment-id || 'none' }}
path: ${{ steps.prepare.outputs.agent_output_artifact_file }}
if-no-files-found: warn
- name: Upload final conclusion artifact
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: final-conclusion-issue-${{ steps.prepare.outputs.issue_number }}-comment-${{ steps.initial_comment.outputs.comment-id || 'none' }}
path: ${{ steps.prepare.outputs.final_conclusion_artifact_file }}
if-no-files-found: warn
- name: Update comment with final result
if: ${{ always() && steps.initial_comment.outputs.comment-id != '' }}
uses: peter-evans/create-or-update-comment@v4
with:
comment-id: ${{ steps.initial_comment.outputs.comment-id }}
edit-mode: replace
body-path: ${{ steps.prepare.outputs.final_comment_file }}
token: ${{ inputs.github-token }}