Skip to content

Commit b22941b

Browse files
authored
feat: make build failure optional with new fail-on-human input (#15)
## Summary - Changed default behavior to not fail builds when human code is detected - Added `fail-on-human` input option (default: false) to control build failure behavior - Changed `post-comment` default to true for better visibility ## Changes This PR makes the action more flexible by not failing builds by default when human code is detected. Instead: - The action will post a comment (now default behavior) - The action will log a warning instead of failing - Users can opt-in to the stricter behavior with `fail-on-human: true` This allows teams to gradually adopt AI-first development practices without immediately blocking all human contributions.
1 parent 698aedd commit b22941b

File tree

4 files changed

+25
-7
lines changed

4 files changed

+25
-7
lines changed

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ jobs:
3535
with:
3636
github-token: ${{ secrets.GITHUB_TOKEN }}
3737
openai-api-key: ${{ secrets.OPENAI_API_KEY }}
38-
post-comment: true # Optional: post a fun comment when humans are detected
38+
post-comment: true # Optional: post a fun comment when humans are detected (default: true)
39+
fail-on-human: false # Optional: fail the build when humans are detected (default: false)
3940
```
4041
4142
## Configuration
@@ -47,7 +48,8 @@ jobs:
4748
| `github-token` | GitHub token for API access | Yes | `${{ github.token }}` |
4849
| `openai-api-key` | OpenAI API key for LLM evaluation | Yes | - |
4950
| `pr-number` | Pull request number to evaluate | No | Auto-detected |
50-
| `post-comment` | Post a comment on PR when human code is detected | No | `false` |
51+
| `post-comment` | Post a comment on PR when human code is detected | No | `true` |
52+
| `fail-on-human` | Fail the build when human code is detected | No | `false` |
5153

5254
### Outputs
5355

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

99102
### 3. Required Permissions

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ inputs:
2020
post-comment:
2121
description: 'Post a comment on PR when human code is detected'
2222
required: false
23+
default: 'true'
24+
fail-on-human:
25+
description: 'Fail the build when human code is detected'
26+
required: false
2327
default: 'false'
2428

2529
outputs:

dist/index.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29971,6 +29971,7 @@ async function run() {
2997129971
const openaiApiKey = core.getInput('openai-api-key', { required: true });
2997229972
const prNumber = parseInt(core.getInput('pr-number') || '0');
2997329973
const postComment = core.getInput('post-comment') === 'true';
29974+
const failOnHuman = core.getInput('fail-on-human') === 'true';
2997429975
if (!prNumber) {
2997529976
core.setFailed('No pull request number provided');
2997629977
return;
@@ -30043,7 +30044,13 @@ async function run() {
3004330044
}
3004430045
// Output results
3004530046
if (overallResult.isHumanLike) {
30046-
core.setFailed(`Code appears to be human-written (${overallResult.confidence.toFixed(1)}% confidence)`);
30047+
const message = `Code appears to be human-written (${overallResult.confidence.toFixed(1)}% confidence)`;
30048+
if (failOnHuman) {
30049+
core.setFailed(message);
30050+
}
30051+
else {
30052+
core.warning(message);
30053+
}
3004730054
}
3004830055
else {
3004930056
core.info(`✅ Code appears to be AI-generated (${overallResult.confidence.toFixed(1)}% confidence)`);

src/index.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ async function run(): Promise<void> {
99
const openaiApiKey = core.getInput('openai-api-key', { required: true });
1010
const prNumber = parseInt(core.getInput('pr-number') || '0');
1111
const postComment = core.getInput('post-comment') === 'true';
12+
const failOnHuman = core.getInput('fail-on-human') === 'true';
1213

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

9697
// Output results
9798
if (overallResult.isHumanLike) {
98-
core.setFailed(
99-
`Code appears to be human-written (${overallResult.confidence.toFixed(1)}% confidence)`
100-
);
99+
const message = `Code appears to be human-written (${overallResult.confidence.toFixed(1)}% confidence)`;
100+
if (failOnHuman) {
101+
core.setFailed(message);
102+
} else {
103+
core.warning(message);
104+
}
101105
} else {
102106
core.info(
103107
`✅ Code appears to be AI-generated (${overallResult.confidence.toFixed(1)}% confidence)`

0 commit comments

Comments
 (0)