Skip to content

Commit 099527f

Browse files
authored
chore: refactor spam filter (#671)
Signed-off-by: Huamin Chen <[email protected]>
1 parent ce7dde6 commit 099527f

File tree

3 files changed

+171
-407
lines changed

3 files changed

+171
-407
lines changed

.github/workflows/anti-spam-comment-moderator.yml

Lines changed: 0 additions & 270 deletions
This file was deleted.
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Anti-Spam Filter (Hidden Logic)
2+
3+
on:
4+
issues:
5+
types: [opened, edited]
6+
pull_request:
7+
types: [opened, edited]
8+
issue_comment:
9+
types: [created, edited]
10+
pull_request_review_comment:
11+
types: [created, edited]
12+
13+
permissions:
14+
issues: write
15+
pull-requests: write
16+
contents: write
17+
18+
jobs:
19+
moderate:
20+
if: ${{ github.event.action == 'created' || github.event.action == 'edited' || github.event.action == 'opened' }}
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: Run spam filter
24+
uses: actions/github-script@v7
25+
env:
26+
# The entire spam detection logic is stored here
27+
SPAM_DETECTION_SCRIPT: ${{ secrets.SPAM_DETECTION_SCRIPT }}
28+
with:
29+
script: |
30+
// Load and execute the spam detection script from secret
31+
const detectionScript = process.env.SPAM_DETECTION_SCRIPT;
32+
33+
if (!detectionScript) {
34+
core.error("SPAM_DETECTION_SCRIPT secret not found!");
35+
core.setFailed("Spam filter not configured");
36+
return;
37+
}
38+
39+
try {
40+
// Execute the hidden script
41+
// The script has access to: github, context, core
42+
const detectSpam = eval(detectionScript);
43+
44+
// Run the detection
45+
await detectSpam(github, context, core);
46+
47+
} catch (err) {
48+
core.error(`Spam filter error: ${err.message}`);
49+
core.setFailed(`Filter execution failed: ${err.message}`);
50+
}
51+

0 commit comments

Comments
 (0)