@@ -2,9 +2,9 @@ name: AI Code Review
22
33permissions :
44 contents : read
5- pull-requests : read
6- issues : read
75 id-token : write
6+ issues : write
7+ pull-requests : write
88
99on :
1010 pull_request :
3838 ai-review :
3939 needs : get-commits
4040 runs-on : ' ubuntu-latest'
41- continue-on-error : true
4241 strategy :
4342 matrix :
4443 commit : ${{ fromJson(needs.get-commits.outputs.commits) }}
@@ -94,21 +93,32 @@ jobs:
9493 Using the prompt `review/review-core.md` and the prompt directory `review`
9594 do a code review of the top commit in the Linux repository.
9695
97- - name : Dump review-inline.txt if exists
96+ # If Claude produced review-inline.txt then it found something
97+ # Post a comment on PR and fail the job
98+ - name : Check review-inline.txt
99+ id : check_review
98100 shell : bash
99101 run : |
100102 review_file=$(find ${{ github.workspace }} -name review-inline.txt)
101- cat $review_file
102103 if [ -s "$review_file" ]; then
103- cp -f $review_file ${{ github.workspace }}/review-inline.txt || true
104- echo "### Inline review" >> $GITHUB_STEP_SUMMARY
105- echo "```" >> $GITHUB_STEP_SUMMARY
106- cat $review_file >> $GITHUB_STEP_SUMMARY
107- echo "```" >> $GITHUB_STEP_SUMMARY
104+ cat $review_file || true
105+ echo "review_file=$review_file" >> $GITHUB_OUTPUT
108106 fi
109107
110- - uses : actions/upload-artifact@v4
108+ - name : Comment on PR
109+ if : steps.check_review.outputs.review_file != ''
110+ uses : actions/github-script@v8
111+ env :
112+ REVIEW_FILE : ${{ steps.check_review.outputs.review_file }}
111113 with :
112- name : ai-review-output
113- if-no-files-found : ignore
114- path : ${{ github.workspace }}/review-inline.txt
114+ github-token : ${{ steps.app-token.outputs.token }}
115+ script : |
116+ const commentScript = require('./ci/claude/post-pr-comment.js');
117+ await commentScript({github, context});
118+
119+ - name : Fail CI job if review file exists
120+ if : steps.check_review.outputs.review_file != ''
121+ run : |
122+ echo "Review file found - failing the CI job"
123+ exit 42
124+
0 commit comments