Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ jobs:
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
openai-api-key: ${{ secrets.OPENAI_API_KEY }}
post-comment: true # Optional: post a fun comment when humans are detected
post-comment: true # Optional: post a fun comment when humans are detected (default: true)
fail-on-human: false # Optional: fail the build when humans are detected (default: false)
```

## Configuration
Expand All @@ -47,7 +48,8 @@ jobs:
| `github-token` | GitHub token for API access | Yes | `${{ github.token }}` |
| `openai-api-key` | OpenAI API key for LLM evaluation | Yes | - |
| `pr-number` | Pull request number to evaluate | No | Auto-detected |
| `post-comment` | Post a comment on PR when human code is detected | No | `false` |
| `post-comment` | Post a comment on PR when human code is detected | No | `true` |
| `fail-on-human` | Fail the build when human code is detected | No | `false` |

### Outputs

Expand Down Expand Up @@ -93,7 +95,8 @@ jobs:
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
openai-api-key: ${{ secrets.OPENAI_API_KEY }}
post-comment: true # Optional: post a fun comment when humans are detected
post-comment: true # Optional: post a fun comment when humans are detected (default: true)
fail-on-human: false # Optional: fail the build when humans are detected (default: false)
```

### 3. Required Permissions
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ inputs:
post-comment:
description: 'Post a comment on PR when human code is detected'
required: false
default: 'true'
fail-on-human:
description: 'Fail the build when human code is detected'
required: false
default: 'false'

outputs:
Expand Down
9 changes: 8 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29971,6 +29971,7 @@ async function run() {
const openaiApiKey = core.getInput('openai-api-key', { required: true });
const prNumber = parseInt(core.getInput('pr-number') || '0');
const postComment = core.getInput('post-comment') === 'true';
const failOnHuman = core.getInput('fail-on-human') === 'true';
if (!prNumber) {
core.setFailed('No pull request number provided');
return;
Expand Down Expand Up @@ -30043,7 +30044,13 @@ async function run() {
}
// Output results
if (overallResult.isHumanLike) {
core.setFailed(`Code appears to be human-written (${overallResult.confidence.toFixed(1)}% confidence)`);
const message = `Code appears to be human-written (${overallResult.confidence.toFixed(1)}% confidence)`;
if (failOnHuman) {
core.setFailed(message);
}
else {
core.warning(message);
}
}
else {
core.info(`✅ Code appears to be AI-generated (${overallResult.confidence.toFixed(1)}% confidence)`);
Expand Down
10 changes: 7 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ async function run(): Promise<void> {
const openaiApiKey = core.getInput('openai-api-key', { required: true });
const prNumber = parseInt(core.getInput('pr-number') || '0');
const postComment = core.getInput('post-comment') === 'true';
const failOnHuman = core.getInput('fail-on-human') === 'true';

if (!prNumber) {
core.setFailed('No pull request number provided');
Expand Down Expand Up @@ -95,9 +96,12 @@ async function run(): Promise<void> {

// Output results
if (overallResult.isHumanLike) {
core.setFailed(
`Code appears to be human-written (${overallResult.confidence.toFixed(1)}% confidence)`
);
const message = `Code appears to be human-written (${overallResult.confidence.toFixed(1)}% confidence)`;
if (failOnHuman) {
core.setFailed(message);
} else {
core.warning(message);
}
} else {
core.info(
`✅ Code appears to be AI-generated (${overallResult.confidence.toFixed(1)}% confidence)`
Expand Down