File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- name : ' Auto Label by Title'
1+ name : " Auto Label by Title"
22
33on :
44 pull_request :
1212 runs-on : ubuntu-latest
1313 # 添加权限配置
1414 permissions :
15- issues : write # 或者 contents: write
15+ issues : write # 或者 contents: write
1616 pull-requests : write
1717 steps :
1818 - name : Label PR based on title keywords
@@ -37,13 +37,20 @@ jobs:
3737 'dependabot': 'dependencies',
3838 'upgrade': 'dependencies',
3939 'security': 'security',
40- 'ci':'ci'
40+ 'ci': 'ci'
4141 };
4242
43- // 检查标题是否包含关键词
44- for (const [keyword, label] of Object.entries(keywordMap)) {
45- if (title.includes(keyword)) {
46- labelsToAdd.add(label);
43+ // 提取标题的第一个单词(冒号前的部分)
44+ const firstPart = title.split(':')[0].trim();
45+ const words = firstPart.split(/\s+/); // 分割成单词数组
46+
47+ // 检查第一个单词或前缀是否匹配关键词
48+ for (const word of words) {
49+ const normalizedWord = word.toLowerCase().replace(/^[\W_]+|[\W_]+$/g, '');
50+
51+ if (keywordMap.hasOwnProperty(normalizedWord)) {
52+ labelsToAdd.add(keywordMap[normalizedWord]);
53+ break; // 找到第一个匹配就停止
4754 }
4855 }
4956
You can’t perform that action at this time.
0 commit comments