[tarball-helper] Add tarball/manual build helper CLI and tests (issue #452) #765
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Spam Protection | ||
| on: | ||
| pull_request_target: | ||
| types: [opened, edited] | ||
| jobs: | ||
| spam-check: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| pull-requests: write | ||
| steps: | ||
| - name: Check for spam patterns | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| const pr = context.payload.pull_request; | ||
| const body = pr.body || ''; | ||
| const files = pr.changed_files; | ||
| const additions = pr.additions; | ||
| // Flag conditions | ||
| const flags = []; | ||
| // Trivial single-file PRs with no description | ||
| if (files === 1 && additions < 30 && body.length < 50) { | ||
| flags.push('trivial-change'); | ||
| } | ||
| // No description at all | ||
| if (!body || body.trim().length < 20) { | ||
| flags.push('missing-description'); | ||
| } | ||
| // New account with burst of PRs (check via API) | ||
| const author = pr.user.login; | ||
| const userPRs = await github.rest.pulls.list({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| state: 'all', | ||
| per_page: 100 | ||
| }); | ||
| const authorPRs = userPRs.data.filter(p => p.user.login === author); | ||
| if (authorPRs.length > 5) { | ||
| const recent = authorPRs.filter(p => { | ||
| const created = new Date(p.created_at); | ||
| const now = new Date(); | ||
| return (now - created) < 24 * 60 * 60 * 1000; // 24 hours | ||
| }); | ||
| if (recent.length > 3) { | ||
| flags.push('burst-activity'); | ||
| } | ||
| } | ||
| if (flags.length > 0) { | ||
| await github.rest.issues.addLabels({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: pr.number, | ||
| labels: ['needs-triage'] | ||
| }); | ||
| await github.rest.issues.createComment({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: pr.number, | ||
| body: '🔍 **Auto-Review Notice** | ||
| This PR was flagged for: ' + flags.join(', ') + ' | ||
| Please ensure: | ||
| - [ ] PR description explains the changes | ||
| - [ ] CLA is signed | ||
| - [ ] Changes are tested | ||
| A maintainer will review shortly.' | ||
| }); | ||
| } | ||