aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/.github/workflows/issue-checker.yml
blob: a59848871d3e71f780034dde2b713d7b6eb7e3e9 (plain) (blame)
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
name: Issue Checker

on:
  issues:
    types: [opened, edited]
  pull_request_target:
    types: [opened, edited]

permissions:
  issues: write
  pull-requests: write

jobs:
  check:
    runs-on: ubuntu-latest
    steps:
      - name: Check and Label Issues
        uses: actions/github-script@v7
        with:
          script: |
            const issue = context.payload.issue || context.payload.pull_request;
            if (!issue) return;
            
            const body = issue.body || '';
            const title = issue.title || '';
            const isIssue = !!context.payload.issue;
            const issueNumber = issue.number;
            
            // Skip if "I have not read carefully" is checked - handled by issue-checkbox-checker.yml
            const hasNotReadChecked = 
              body.includes('- [x] I have not read carefully') ||
              body.includes('- [X] I have not read carefully') ||
              body.includes('- [x] 我未仔细阅读') ||
              body.includes('- [X] 我未仔细阅读');
            
            if (hasNotReadChecked) {
              // Let issue-checkbox-checker handle this
              return;
            }
            
            const labels = [];
            
            // Platform labels
            if (body.match(/Windows|windows/i)) labels.push('platform: windows');
            if (body.match(/macOS|macos|Mac/i)) labels.push('platform: macos');
            if (body.match(/Linux|linux|Ubuntu|Debian|Arch|Fedora/i)) labels.push('platform: linux');
            
            // Mod loader labels
            if (body.match(/Fabric/i)) labels.push('mod-loader: fabric');
            if (body.match(/Forge/i)) labels.push('mod-loader: forge');
            
            // Java related
            if (body.match(/Java|java|JRE|JDK/i)) labels.push('java');
            
            // Authentication issues
            if (body.match(/login|authentication|Microsoft|Xbox|account/i)) labels.push('authentication');
            
            // Download issues
            if (body.match(/download|downloading|assets|libraries/i)) labels.push('download');
            
            // Launch issues
            if (body.match(/launch|start|won't start|crash|crashed/i)) labels.push('launch');
            
            // UI issues
            if (body.match(/UI|interface|display|rendering|visual/i)) labels.push('ui');
            
            // Performance issues
            if (body.match(/slow|performance|lag|freeze|hang/i)) labels.push('performance');
            
            // Check for unclear titles
            if (isIssue && (title.length < 10 ||
                title.match(/^(help|问题|stuck|卡住|error|错误|bug)$/i))) {
              labels.push('needs-clarification');
            }
            
            // Apply labels
            if (labels.length > 0) {
              await github.rest.issues.addLabels({
                owner: context.repo.owner,
                repo: context.repo.repo,
                issue_number: issue.number,
                labels: labels
              });
            }