File tree Expand file tree Collapse file tree 1 file changed +54
-0
lines changed
Expand file tree Collapse file tree 1 file changed +54
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Anti-Spam Filter
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+ SPAM_DETECTION_SCRIPT : ${{ secrets.SPAM_DETECTION_SCRIPT }}
27+ with :
28+ script : |
29+ const raw = process.env.SPAM_DETECTION_SCRIPT;
30+
31+ if (!raw) {
32+ core.warning("SPAM_DETECTION_SCRIPT secret not configured.");
33+ return;
34+ }
35+
36+ try {
37+ const factory = eval(raw); // factory = (module)=> fn
38+
39+ if (typeof factory !== "function") {
40+ throw new Error("Secret must export (module)=>function");
41+ }
42+
43+ // 调用工厂函数
44+ const detectSpam = factory({});
45+
46+ if (typeof detectSpam !== "function") {
47+ throw new Error("Factory did not return a function");
48+ }
49+
50+ await detectSpam(github, context, core);
51+
52+ } catch (err) {
53+ core.error("Spam filter error: " + err.message);
54+ }
You can’t perform that action at this time.
0 commit comments