Skip to content

Respond to Review Comments #11

Respond to Review Comments

Respond to Review Comments #11

Workflow file for this run

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
}