返回 DeepSeek-TUI-2026
spam-lockdown.yml
根目录 / .github / workflows / spam-lockdown.yml
1 name: Lock down obvious spam issues
2
3 on:
4 issues:
5 types: [opened]
6
7 permissions:
8 issues: write
9
10 jobs:
11 lockdown:
12 runs-on: ubuntu-latest
13 steps:
14 - name: Auto-close spam patterns from new accounts
15 uses: actions/github-script@v7
16 with:
17 script: |
18 const issue = context.payload.issue;
19 const author = issue.user;
20
21 // Only consider brand-new accounts. If the user has been around
22 // long enough to file good-faith issues elsewhere, don't touch.
23 const created = new Date(author.created_at || 0);
24 const ageDays = (Date.now() - created.getTime()) / 86_400_000;
25 if (ageDays > 30) return;
26
27 const blob = `${issue.title || ''}\n${issue.body || ''}`;
28 const patterns = [
29 /\bcrypto\b/i,
30 /\bairdrop\b/i,
31 /\bnft\b/i,
32 /\bpresale\b/i,
33 /\busdt\b/i,
34 /\btg\s*@/i,
35 /\btelegram\s+@/i,
36 /\bt\.me\//i,
37 /\bwhatsapp\s+\+/i,
38 /\bseo\s+service/i,
39 /\bguest\s+post/i,
40 /\bbacklink/i,
41 /\bbuy\s+followers/i,
42 /\bjoin\s+our\s+(community|server|group)/i,
43 /\bpromot[ei]\s+your\b/i,
44 ];
45 const hit = patterns.find(p => p.test(blob));
46 if (!hit) return;
47
48 await github.rest.issues.createComment({
49 owner: context.repo.owner,
50 repo: context.repo.repo,
51 issue_number: issue.number,
52 body: [
53 'This issue was auto-closed because the title or body matches',
54 'a spam pattern (paid promotion / unrelated link) and the author',
55 'account is less than 30 days old. If this is a real bug or',
56 'feature request, please reopen with a clearer description',
57 '(in English or 中文) of the project-relevant context.',
58 ].join(' '),
59 });
60
61 await github.rest.issues.update({
62 owner: context.repo.owner,
63 repo: context.repo.repo,
64 issue_number: issue.number,
65 state: 'closed',
66 state_reason: 'not_planned',
67 });
68
69 await github.rest.issues.addLabels({
70 owner: context.repo.owner,
71 repo: context.repo.repo,
72 issue_number: issue.number,
73 labels: ['spam'],
74 }).catch(() => {}); // ignore if label doesn't exist yet
75
75 lines YAML