| 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 | timeout-minutes: 10 |
| 14 | steps: |
| 15 | - name: Auto-close spam patterns from new accounts |
| 16 | uses: actions/github-script@v9 |
| 17 | with: |
| 18 | script: | |
| 19 | const issue = context.payload.issue; |
| 20 | const author = issue.user; |
| 21 | |
| 22 | // Only consider brand-new accounts. If the user has been around |
| 23 | // long enough to file good-faith issues elsewhere, don't touch. |
| 24 | const created = new Date(author.created_at || 0); |
| 25 | const ageDays = (Date.now() - created.getTime()) / 86_400_000; |
| 26 | if (ageDays > 30) return; |
| 27 | |
| 28 | const blob = `${issue.title || ''}\n${issue.body || ''}`; |
| 29 | const patterns = [ |
| 30 | /\bcrypto\b/i, |
| 31 | /\bairdrop\b/i, |
| 32 | /\bnft\b/i, |
| 33 | /\bpresale\b/i, |
| 34 | /\busdt\b/i, |
| 35 | /\btg\s*@/i, |
| 36 | /\btelegram\s+@/i, |
| 37 | /\bt\.me\//i, |
| 38 | /\bwhatsapp\s+\+/i, |
| 39 | /\bseo\s+service/i, |
| 40 | /\bguest\s+post/i, |
| 41 | /\bbacklink/i, |
| 42 | /\bbuy\s+followers/i, |
| 43 | /\bjoin\s+our\s+(community|server|group)/i, |
| 44 | /\bpromot[ei]\s+your\b/i, |
| 45 | ]; |
| 46 | const hit = patterns.find(p => p.test(blob)); |
| 47 | if (!hit) return; |
| 48 | |
| 49 | // Label and close; no comment (founder, 2026-09-22). The label |
| 50 | // description tells a false positive how to get the issue back. |
| 51 | try { |
| 52 | await github.rest.issues.createLabel({ |
| 53 | owner: context.repo.owner, |
| 54 | repo: context.repo.repo, |
| 55 | name: 'spam', |
| 56 | color: 'b60205', |
| 57 | description: 'Auto-closed: spam pattern from a <30-day account. Real report? Reopen with project context', |
| 58 | }); |
| 59 | } catch (error) { |
| 60 | if (error.status !== 422) throw error; // 422: label already exists |
| 61 | } |
| 62 | |
| 63 | await github.rest.issues.update({ |
| 64 | owner: context.repo.owner, |
| 65 | repo: context.repo.repo, |
| 66 | issue_number: issue.number, |
| 67 | state: 'closed', |
| 68 | state_reason: 'not_planned', |
| 69 | }); |
| 70 | |
| 71 | await github.rest.issues.addLabels({ |
| 72 | owner: context.repo.owner, |
| 73 | repo: context.repo.repo, |
| 74 | issue_number: issue.number, |
| 75 | labels: ['spam'], |
| 76 | }); |
| 77 |