Skip to content

Commit cd3bb60

Browse files
committed
Make minimizing comments configurable
1 parent 566146b commit cd3bb60

5 files changed

Lines changed: 26 additions & 11 deletions

File tree

README.md

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,27 +27,34 @@ jobs:
2727
issues: write
2828
pull-requests: write
2929
models: read
30+
contents: read
3031
steps:
3132
- uses: actions/checkout@v4
3233
- uses: github/ai-spam-guard
3334
with:
3435
token: ${{ secrets.GITHUB_TOKEN }}
3536
spam-label: 'spam'
3637
ai-label: 'ai-generated'
38+
minimize-detected-comments: true
3739
```
3840
3941
### Configuration
4042
41-
| Input | Description | Default | Required |
42-
| ------------ | ------------------------------------------------------ | --------------------- | -------- |
43-
| `token` | GitHub token with issues and pull-requests permissions | `${{ github.token }}` | No |
44-
| `spam-label` | Label to add when generic spam is detected | `spam` | No |
45-
| `ai-label` | Label to add when AI-generated content is detected | `ai-generated` | No |
43+
| Input | Description | Default | Required |
44+
| ---------------------------- | ------------------------------------------------------ | --------------------- | -------- |
45+
| `token` | GitHub token with issues and pull-requests permissions | `${{ github.token }}` | No |
46+
| `spam-label` | Label to add when generic spam is detected | `spam` | No |
47+
| `ai-label` | Label to add when AI-generated content is detected | `ai-generated` | No |
48+
| `minimize-detected-comments` | Whether to minimize comments detected as spam | `true` | No |
4649

47-
### Environment Variables
50+
### Inference
4851

49-
The action no longer requires external API keys - it uses the built-in GitHub
50-
token with `models: read` permission to access GitHub Models.
52+
The action does not require any external API keys for inference - it uses the
53+
built-in GitHub token with `models: read` permission to access GitHub Models.
54+
55+
Every GitHub user has Github Models inference for free, but if you're running
56+
into rate limiting issues you can choose to
57+
[opt in to paid usage](https://docs.github.com/en/billing/managing-billing-for-your-products/about-billing-for-github-models).
5158

5259
## Detection Prompts
5360

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ inputs:
2222
description: 'Label to add when AI-generated content is detected'
2323
required: false
2424
default: 'ai-generated'
25+
minimize-detected-comments:
26+
description: 'Whether to minimize comments detected as spam'
27+
required: false
28+
default: 'true'
2529

2630
runs:
2731
using: 'node16'

dist/index.js

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ async function run(): Promise<void> {
1515
const promptsDir = path.resolve(__dirname, '..', 'prompts') // Use built-in prompts
1616
const spamLabel = core.getInput('spam-label')
1717
const aiLabel = core.getInput('ai-label')
18+
const minimizeComments = core.getBooleanInput('minimize-detected-comments')
1819

1920
const openai = new OpenAI({
2021
apiKey: token,
@@ -60,7 +61,8 @@ async function run(): Promise<void> {
6061
}
6162

6263
// Only minimize comments if they are spam, not just AI-generated
63-
if (commentNodeId && flags.spam) {
64+
// and if minimize-detected-comments is enabled
65+
if (commentNodeId && flags.spam && minimizeComments) {
6466
await minimizeComment(octokit, commentNodeId)
6567
core.info(`Comment ${commentNodeId} minimized as spam`)
6668
}

0 commit comments

Comments
 (0)