I have been trying to use github actions to place a comment inline in the pull request diff. I have tried to follow this documentation: review-comment-in-diff however nothing seemed to work as expected. The documentation seems to state that you can just use the property position, but other docs say you need commit_id and path for it to work create-a-comment. If I do not add commit_id or path, I get an error message that they are missing, if I add it I get a validation error. I will show both below. Note that the first error message also mentions missing in_reply_to and line which according to the documentation is not needed for creating a new comment using position.
- name: publish line comment curl
if: contains(env.SCRIPT_OUTPUT, 'FAIL')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
curl \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/comments \
-H "Authorization: token $GITHUB_TOKEN" \
--data '{ "body": "blah blah" ,
"path": "SomeDir/SomeFile.json",
"position": 1
}'
{ "message": "Invalid request.\n\nNo subschema in "oneOf" matched.\n"commit_id" wasn't supplied.\n"in_reply_to" wasn't supplied.\n"position" is not a permitted key.\n"commit_id", "line" weren't supplied.",
--data '{ "body": "blah blah" ,
"path": "SomeDir/SomeFile.json",
"position": 1,
"commit_id": "${{ github.sha }}"
}'
"message": "Validation Failed", "errors": [ { "resource": "PullRequestReviewComment", "code": "custom", "field": "pull_request_review_thread.end_commit_oid", "message": "pull_request_review_thread.end_commit_oid is not part of the pull request"