Skip to content

Commit 81159c3

Browse files
authored
Merge pull request #42 from dsanders11/feat/dry-run-input
Add input for dry-run mode
2 parents 6cac571 + 4d26b05 commit 81159c3

File tree

6 files changed

+40
-10
lines changed

6 files changed

+40
-10
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ jobs:
5555
| `spam-label` | Label to add when generic spam is detected | `spam` | No |
5656
| `ai-label` | Label to add when AI-generated content is detected | `ai-generated` | No |
5757
| `minimize-detected-comments` | Whether to minimize comments detected as spam | `true` | No |
58+
| `dry-run` | If true, only evaluate without adding labels or minimizing comments | `false` | No |
5859
| `custom-prompt-path` | Path to a custom YAML prompt file in your repository (relative to repository root) | (none) | No |
5960
| `enable-spam-detection` | Enable built-in spam detection prompt | `true` | No |
6061
| `enable-link-spam-detection` | Enable built-in link spam detection prompt | `true` | No |

action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ inputs:
2626
description: 'Whether to minimize comments detected as spam'
2727
required: false
2828
default: 'true'
29+
dry-run:
30+
description:
31+
'If true, only evaluate without adding labels or minimizing comments'
32+
required: false
33+
default: 'false'
2934
custom-prompt-path:
3035
description:
3136
'Path to a custom YAML prompt file in your repository (relative to

badges/coverage.svg

Lines changed: 1 addition & 1 deletion
Loading

dist/index.js

Lines changed: 15 additions & 4 deletions
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: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ async function run(): Promise<void> {
1818
const minimizeComments = core.getBooleanInput('minimize-detected-comments')
1919
const customPromptPath = core.getInput('custom-prompt-path')
2020
const endpoint = core.getInput('endpoint')
21+
const dryRun = core.getBooleanInput('dry-run')
2122

2223
// Built-in prompt configuration
2324
const enableSpamDetection = core.getBooleanInput('enable-spam-detection')
@@ -75,15 +76,27 @@ async function run(): Promise<void> {
7576
}
7677

7778
if (issueNumber && labels.length > 0) {
78-
await addLabels(octokit, github.context, issueNumber, labels)
79-
core.info(`Added labels [${labels.join(', ')}] to issue #${issueNumber}`)
79+
if (dryRun) {
80+
core.info(
81+
`[DRY RUN] Would add labels [${labels.join(', ')}] to issue #${issueNumber}`
82+
)
83+
} else {
84+
await addLabels(octokit, github.context, issueNumber, labels)
85+
core.info(
86+
`Added labels [${labels.join(', ')}] to issue #${issueNumber}`
87+
)
88+
}
8089
}
8190

8291
// Only minimize comments if they are spam, not just AI-generated
8392
// and if minimize-detected-comments is enabled
8493
if (commentNodeId && flags.spam && minimizeComments) {
85-
await minimizeComment(octokit, commentNodeId)
86-
core.info(`Comment ${commentNodeId} minimized as spam`)
94+
if (dryRun) {
95+
core.info(`[DRY RUN] Would minimize comment ${commentNodeId} as spam`)
96+
} else {
97+
await minimizeComment(octokit, commentNodeId)
98+
core.info(`Comment ${commentNodeId} minimized as spam`)
99+
}
87100
}
88101
} catch (error) {
89102
core.setFailed((error as Error).message)

0 commit comments

Comments
 (0)