File tree Expand file tree Collapse file tree 4 files changed +25
-7
lines changed
Expand file tree Collapse file tree 4 files changed +25
-7
lines changed Original file line number Diff line number Diff line change 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
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
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
Original file line number Diff line number Diff 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
2529outputs :
Original file line number Diff line number Diff 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)`);
Original file line number Diff line number Diff 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)`
You can’t perform that action at this time.
0 commit comments