|
1 | | -name: Auto Manage Specific Issues |
| 1 | +# .github/workflows/auto-block-issues.yml |
| 2 | + |
| 3 | +name: Auto Block Sensitive Issues |
2 | 4 |
|
3 | 5 | on: |
4 | 6 | issues: |
5 | 7 | types: [opened, edited] |
6 | 8 |
|
7 | 9 | jobs: |
8 | | - auto-manage-issues: |
9 | | - # Only run for non-owners to avoid processing own issues |
| 10 | + auto-block-issues: |
| 11 | + # Skip processing if the issue is opened/edited by the repository owner |
10 | 12 | if: github.actor != github.event.repository.owner.login |
11 | 13 | runs-on: ubuntu-latest |
12 | 14 | steps: |
13 | | - - name: Check issue content for specific keywords |
| 15 | + - name: Detect and block sensitive issues |
14 | 16 | uses: actions/github-script@v7 |
15 | 17 | with: |
16 | 18 | script: | |
17 | | - // Get issue title and body (case-insensitive matching) |
| 19 | + // Get issue title and body (converted to lowercase) |
18 | 20 | const title = context.payload.issue.title.toLowerCase(); |
19 | 21 | const body = context.payload.issue.body?.toLowerCase() || ''; |
20 | 22 | |
21 | | - // Bilingual keyword list (Chinese + English) |
22 | | - const sensitiveKeywords = [ |
| 23 | + // List of sensitive keywords in both Chinese and English |
| 24 | + const blockKeywords = [ |
23 | 25 | // Chinese keywords |
24 | 26 | '刷星', '刷赞', '买星', '买赞', '虚假star', '假星', |
25 | 27 | '可疑账号', '刷热度', '买热度', 'basinarapprowayl', |
| 28 | + '刷issue', '刷评论', '买issue', '买评论', '虚假issue', '假issue', |
| 29 | + '刷贡献', '买贡献', '贡献造假', 'issue 刷量', '评论 刷量', |
26 | 30 | |
27 | 31 | // English keywords |
28 | 32 | 'star farming', 'buy star', 'fake star', 'fake stars', |
29 | 33 | 'artificial stars', 'star manipulation', 'buy github stars', |
30 | | - 'suspicious account', 'bot accounts' |
| 34 | + 'suspicious account', 'bot accounts', 'issue farming', |
| 35 | + 'comment spam', 'spam comments', 'fake issue', 'fake issues', |
| 36 | + 'buy issue', 'buy issues', 'buy comments', 'contribution fraud', |
| 37 | + 'activity farming', 'gaming the system' |
31 | 38 | ]; |
32 | 39 | |
33 | | - // Check if content contains any sensitive keywords |
34 | | - const hasSensitiveContent = sensitiveKeywords.some(keyword => |
| 40 | + // Check if the title or body contains any of the sensitive keywords |
| 41 | + const shouldBlock = blockKeywords.some(keyword => |
35 | 42 | title.includes(keyword.toLowerCase()) || |
36 | 43 | body.includes(keyword.toLowerCase()) |
37 | 44 | ); |
38 | 45 | |
39 | | - if (hasSensitiveContent) { |
40 | | - console.log(`Sensitive content detected in issue #${context.issue.number}. Processing...`); |
| 46 | + if (shouldBlock) { |
| 47 | + console.log(`Blocking sensitive issue #${context.issue.number}`); |
41 | 48 | |
42 | | - // 1. Add labels (ensure these labels exist in your repository) |
| 49 | + // 1. Add a blocked label |
43 | 50 | try { |
44 | 51 | await github.rest.issues.addLabels({ |
45 | 52 | owner: context.repo.owner, |
46 | 53 | repo: context.repo.repo, |
47 | 54 | issue_number: context.issue.number, |
48 | | - labels: ['🚩auto-flagged', '⚠️needs-review'] |
| 55 | + labels: ['🚫 blocked'] |
49 | 56 | }); |
50 | | - console.log('Labels added successfully'); |
51 | 57 | } catch (error) { |
52 | | - console.log('Failed to add labels, they may not exist:', error); |
| 58 | + console.log('Failed to add label:', error); |
53 | 59 | } |
54 | 60 | |
55 | | - // 2. Add automated response comment |
| 61 | + // 2. Add an automated comment explaining the action |
56 | 62 | await github.rest.issues.createComment({ |
57 | 63 | owner: context.repo.owner, |
58 | 64 | repo: context.repo.repo, |
59 | 65 | issue_number: context.issue.number, |
60 | 66 | body: `--- |
61 | | -**🔍 Automated Detection Notice** |
62 | | - |
63 | | -This issue has been automatically flagged due to detected keywords related to community guidelines. |
| 67 | +**⚠️ Content Blocked Notification** |
64 | 68 |
|
65 | | -The maintainer team focuses on keeping discussions centered around **technical development, feature implementation, and bug fixes**. Meta-discussions about project popularity metrics are noted and handled through appropriate channels. |
| 69 | +This issue has been automatically blocked because it contains restricted content. The project maintenance team only accepts technical discussions related to code development, feature implementation, and bug fixes. |
66 | 70 |
|
67 | | -**Next steps:** |
68 | | -- This issue will be reviewed by maintainers |
69 | | -- If content is duplicate or off-topic, the issue may be closed |
70 | | -- Thank you for your understanding and cooperation |
| 71 | +According to our community guidelines, meta-discussions about project popularity, Star counts, or any form of artificial activity are not within the scope of this repository. |
71 | 72 |
|
72 | | -*This is an automated response*` |
| 73 | +*This action was performed by an automated system.*` |
73 | 74 | }); |
74 | 75 |
|
75 | | - // 3. 【Optional】Close issue immediately - uncomment below to enable |
76 | | - /* |
| 76 | + // 3. Immediately close the issue |
77 | 77 | await github.rest.issues.update({ |
78 | 78 | owner: context.repo.owner, |
79 | 79 | repo: context.repo.repo, |
80 | 80 | issue_number: context.issue.number, |
81 | 81 | state: 'closed' |
82 | 82 | }); |
83 | | - console.log('Issue closed automatically'); |
84 | | - */ |
85 | 83 |
|
86 | | - // 4. 【Optional】Lock issue - uncomment below to enable |
87 | | - /* |
| 84 | + // 4. Lock the issue to prevent further comments |
88 | 85 | await github.rest.issues.lock({ |
89 | 86 | owner: context.repo.owner, |
90 | 87 | repo: context.repo.repo, |
91 | 88 | issue_number: context.issue.number |
92 | 89 | }); |
93 | | - console.log('Issue locked'); |
94 | | - */ |
95 | 90 |
|
| 91 | + console.log('Issue has been closed and locked'); |
96 | 92 | } else { |
97 | | - console.log('No sensitive content detected. Skipping processing.'); |
| 93 | + console.log('No sensitive content detected, skipping processing'); |
98 | 94 | } |
0 commit comments