Respond to Review Comments #11
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Respond to Review Comments | |
on: | |
pull_request_review_comment: | |
types: [created] | |
jobs: | |
respond-to-comment: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v3 | |
- name: Respond to Comment | |
env: | |
COMMENT_ID: ${{ github.event.comment.id }} | |
PULL_NUMBER: ${{ github.event.pull_request.number }} | |
REPO: ${{ github.repository }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
# First, fetch details about the original comment to get necessary context | |
COMMENT_DATA=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \ | |
-H "Accept: application/vnd.github.v3+json" \ | |
https://api.github.com/repos/$REPO/pulls/comments/$COMMENT_ID) | |
# Extract necessary details from the original comment data | |
COMMIT_ID=$(echo $COMMENT_DATA | jq -r '.commit_id') | |
PATH=$(echo $COMMENT_DATA | jq -r '.path') | |
POSITION=$(echo $COMMENT_DATA | jq -r '.position') | |
# Post a new comment in the same context as the original comment | |
curl -X POST \ | |
-H "Authorization: token $GITHUB_TOKEN" \ | |
-H "Accept: application/vnd.github.v3+json" \ | |
https://api.github.com/repos/$REPO/pulls/$PULL_NUMBER/comments \ | |
-d @- << EOF | |
{ | |
"body": "Thanks for your reply!", | |
"commit_id": "$COMMIT_ID", | |
"path": "$PATH", | |
"position": $POSITION | |
} |