forked from Anxcye/anx-reader
-
Notifications
You must be signed in to change notification settings - Fork 0
108 lines (93 loc) · 6.55 KB
/
Copy pathlabel-trigger.yml
File metadata and controls
108 lines (93 loc) · 6.55 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
name: Label Trigger Actions
on:
issues:
types: [labeled]
jobs:
handle-special-labels:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- name: Validate Bug Report
if: github.event.label.name == 'bug'
uses: actions/github-script@v7
with:
script: |
const issue = context.issue;
const issueBody = context.payload.issue.body || '';
// Check if platform information is complete
const platformSection = issueBody.match(/- Platform:.*?\n.*?- OS:.*?\n.*?- AnxReader Version:.*?\n.*?- Device:.*?\n/s);
if (!platformSection) {
console.log('Platform section not found');
return;
}
const platformText = platformSection[0];
// Check for incomplete/default values
const incompletePatterns = [
/\[e\.g\.\s+Android\]/,
/\[e\.g\.\s+Android13\(MIUI14\)\]/,
/\[e\.g\.\s+1\.2\.0\+2033\]/,
/\[e\.g\.\s+Xiaomi\s+13\]/,
/- Platform:\s*\|\s*平台:\s*$/m,
/- OS:\s*\|\s*操作系统:\s*$/m,
/- AnxReader Version:\s*\|\s*安读版本:\s*$/m,
/- Device:\s*\|\s*设备:\s*$/m
];
const isIncomplete = incompletePatterns.some(pattern => pattern.test(platformText));
if (isIncomplete) {
// Add question label
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
labels: ['question']
});
// Add comment
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
body: "👋 感谢您提交bug报告!\n\n我注意到您的平台信息可能不够完整。为了更好地帮助您解决问题,请提供以下完整信息:\n\n- **Platform | 平台**:(如: Android, iOS, Windows, macOS, Linux)\n- **OS | 操作系统**:(如: Android 13 (MIUI 14), iOS 17.1, Windows 11) \n- **AnxReader Version | 安读版本**:(如: 1.6.3+2100,可在应用设置中查看)\n- **Device | 设备**:(如: Xiaomi 13, iPhone 15, ThinkPad X1)\n\n请编辑您的issue并填写完整的平台信息,这将帮助我们更快地定位和解决问题。\n\n---\n\nThank you for submitting this bug report!\n\nI noticed that your platform information might be incomplete. To better help you solve the issue, please provide complete information for:\n\n- **Platform**: (e.g., Android, iOS, Windows, macOS, Linux)\n- **OS**: (e.g., Android 13 (MIUI 14), iOS 17.1, Windows 11)\n- **AnxReader Version**: (e.g., 1.6.3+2100, check in app settings)\n- **Device**: (e.g., Xiaomi 13, iPhone 15, ThinkPad X1)\n\nPlease edit your issue and fill in the complete platform information to help us locate and resolve the issue faster."
});
}
- name: Handle need-test-file Label
if: github.event.label.name == 'need-test-file'
uses: actions/github-script@v7
with:
script: |
const issue = context.issue;
// Add question label
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
labels: ['question']
});
// Add comment requesting test file
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
body: "📁 **需要测试文件 | Test File Required**\n\n为了更好地重现和解决您遇到的问题,我们需要您提供相关的测试文件。\n\n请提供:\n- 出现问题的书籍文件(epub、pdf、txt等)\n- 或者能够重现问题的最小示例文件\n- 如果涉及特定格式,请说明文件的具体格式和来源\n\n您可以:\n1. 直接拖拽文件到此评论区上传\n2. 提供文件的下载链接\n3. 如果文件较大,可以使用网盘分享\n\n**注意**:如果涉及版权内容,请提供公开或自创的测试文件。\n\n---\n\nTo better reproduce and resolve the issue you encountered, we need you to provide relevant test files.\n\nPlease provide:\n- The book file where the problem occurs (epub, pdf, txt, etc.)\n- Or a minimal example file that can reproduce the issue \n- If it involves a specific format, please specify the file format and source\n\nYou can:\n1. Drag and drop files directly to this comment area to upload\n2. Provide download links for the files\n3. Use cloud storage sharing if the files are large\n\n**Note**: If copyrighted content is involved, please provide public or self-created test files."
});
- name: Handle need-more-info Label
if: github.event.label.name == 'need-more-info'
uses: actions/github-script@v7
with:
script: |
const issue = context.issue;
// Add question label
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
labels: ['question']
});
// Add comment requesting more information
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
body: "ℹ️ **需要更多信息 | More Information Required**\n\n为了更好地帮助您解决问题,我们需要更多详细信息。\n\n请提供:\n- 详细的操作步骤\n- 错误信息的完整截图或日志\n- 问题出现的具体场景\n- 您的设备和软件版本信息\n- 任何可能相关的其他信息\n\n请编辑您的原始issue或在评论中补充这些信息。\n\n---\n\nTo better help you solve the issue, we need more detailed information.\n\nPlease provide:\n- Detailed steps to reproduce\n- Complete screenshots or logs of error messages\n- Specific scenarios where the issue occurs\n- Your device and software version information \n- Any other potentially relevant information\n\nPlease edit your original issue or add this information in the comments."
});