Skip to content

Commit 7e882d3

Browse files
authored
Merge pull request #22 from LangMem/feat/cc_ci
feat: enhance auto comment workflow to support discussions and improv…
2 parents f872125 + ecb83be commit 7e882d3

File tree

3 files changed

+60
-28
lines changed

3 files changed

+60
-28
lines changed

.github/workflows/auto-comment-for-clarity.yml

Lines changed: 55 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ name: Auto Comment for Clarity
1616
on:
1717
issues:
1818
types: [opened]
19+
discussions:
20+
types: [created]
1921
jobs:
2022
auto-comment:
2123
runs-on: ubuntu-latest
@@ -33,27 +35,44 @@ jobs:
3335
with:
3436
github-token: ${{ secrets.GITHUB_TOKEN }}
3537
script: |
36-
const issue_number = context.issue.number;
3738
const owner = context.repo.owner;
3839
const repo = context.repo.repo;
40+
41+
// Handle both issues and discussions
42+
let title, body, number, targetType, targetUrl;
43+
44+
if (context.eventName === 'issues') {
45+
number = context.issue.number;
46+
title = context.payload.issue.title || '';
47+
body = context.payload.issue.body || '';
48+
targetType = 'issue';
49+
targetUrl = context.payload.issue.html_url;
50+
} else if (context.eventName === 'discussions') {
51+
number = context.payload.discussion.number;
52+
title = context.payload.discussion.title || '';
53+
body = context.payload.discussion.body || '';
54+
targetType = 'discussion';
55+
targetUrl = context.payload.discussion.html_url;
56+
} else {
57+
console.log('Unsupported event type:', context.eventName);
58+
return;
59+
}
3960
40-
// Get issue details
41-
const issueTitle = context.payload.issue.title || '';
42-
const issueBody = context.payload.issue.body || '';
43-
44-
console.log('Issue Title:', issueTitle);
45-
console.log('Issue Body:', issueBody);
61+
console.log('Target Type:', targetType);
62+
console.log('Target Number:', number);
63+
console.log('Title:', title);
64+
console.log('Body:', body);
4665
4766
// Analyze what's missing specifically
48-
const hasDetailedDescription = issueBody.length > 50 && !issueBody.includes('No response');
49-
const hasStepsToReproduce = issueBody.toLowerCase().includes('步骤') || issueBody.toLowerCase().includes('重现') || issueBody.toLowerCase().includes('reproduce');
50-
const hasEnvironmentInfo = issueBody.toLowerCase().includes('环境') || issueBody.toLowerCase().includes('版本') || issueBody.toLowerCase().includes('version');
51-
const hasExpectedBehavior = issueBody.toLowerCase().includes('期望') || issueBody.toLowerCase().includes('expected');
52-
const hasErrorDetails = issueBody.toLowerCase().includes('错误') || issueBody.toLowerCase().includes('error') || issueBody.toLowerCase().includes('异常');
67+
const hasDetailedDescription = body.length > 50 && !body.includes('No response');
68+
const hasStepsToReproduce = body.toLowerCase().includes('步骤') || body.toLowerCase().includes('重现') || body.toLowerCase().includes('reproduce');
69+
const hasEnvironmentInfo = body.toLowerCase().includes('环境') || body.toLowerCase().includes('版本') || body.toLowerCase().includes('version');
70+
const hasExpectedBehavior = body.toLowerCase().includes('期望') || body.toLowerCase().includes('expected');
71+
const hasErrorDetails = body.toLowerCase().includes('错误') || body.toLowerCase().includes('error') || body.toLowerCase().includes('异常');
5372
5473
// Check if this looks like a bug report that needs more info
55-
const isBugReport = issueTitle.toLowerCase().includes('bug') || issueTitle.toLowerCase().includes('错误');
56-
const hasVeryShortDescription = issueBody.trim().length < 30 || issueBody === 'No response' || issueBody.includes('这个怎么用') || issueBody.includes('不知道为什么');
74+
const isBugReport = title.toLowerCase().includes('bug') || title.toLowerCase().includes('错误');
75+
const hasVeryShortDescription = body.trim().length < 30 || body === 'No response' || body.includes('这个怎么用') || body.includes('不知道为什么');
5776
5877
// Generate dynamic comment based on what's missing
5978
const missingItems = [];
@@ -87,7 +106,7 @@ jobs:
87106
// Only comment if there are missing items
88107
if (missingItems.length > 0) {
89108
let commentLines = [
90-
'👋 感谢您提交这个 issue!',
109+
'👋 感谢您提交这个 ' + (targetType === 'issue' ? 'issue' : 'discussion') + '!',
91110
'',
92111
'为了更好地帮助您解决问题,我发现以下信息需要补充:',
93112
''
@@ -99,21 +118,32 @@ jobs:
99118
});
100119
101120
commentLines.push('');
102-
commentLines.push('请编辑您的原始 issue 来添加这些信息,这将帮助我们更快地定位和解决问题。🙏');
121+
commentLines.push('请编辑您的原始' + (targetType === 'issue' ? 'issue' : 'discussion') + '来添加这些信息,这将帮助我们更快地定位和解决问题。🙏');
103122
commentLines.push('');
104123
commentLines.push('---');
105-
commentLines.push('*这是一个自动生成的提醒,旨在提高 issue 的质量和解决效率。*');
124+
commentLines.push('*这是一个自动生成的提醒,旨在提高' + (targetType === 'issue' ? 'issue' : 'discussion') + '的质量和解决效率。*');
106125
107126
const commentBody = commentLines.join('\n');
108127
109-
await github.rest.issues.createComment({
110-
owner,
111-
repo,
112-
issue_number,
113-
body: commentBody
114-
});
115-
console.log('Posted targeted clarity request comment to issue #' + issue_number);
128+
// Create comment based on target type
129+
if (targetType === 'issue') {
130+
await github.rest.issues.createComment({
131+
owner,
132+
repo,
133+
issue_number: number,
134+
body: commentBody
135+
});
136+
} else if (targetType === 'discussion') {
137+
await github.rest.repos.createDiscussionComment({
138+
owner,
139+
repo,
140+
discussion_number: number,
141+
body: commentBody
142+
});
143+
}
144+
145+
console.log('Posted targeted clarity request comment to ' + targetType + ' #' + number);
116146
console.log('Missing items:', missingItems.join(', '));
117147
} else {
118-
console.log('Issue has sufficient information, no comment needed');
148+
console.log(targetType + ' has sufficient information, no comment needed');
119149
}

.github/workflows/issue-translation.yml

Whitespace-only changes.

.github/workflows/issue-triage.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
name: Issue Triage
15+
name: Issue Triage (Disabled)
16+
# Temporarily disabled to prevent duplicate comments
1617
on:
17-
issues:
18-
types: [opened]
18+
workflow_dispatch: # Manual trigger only
19+
# issues:
20+
# types: [opened]
1921
env:
2022
ANTHROPIC_BASE_URL: "https://open.bigmodel.cn/api/anthropic"
2123
jobs:

0 commit comments

Comments
 (0)