Respond to Review Comments #18
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_REQUEST_NUMBER: ${{ github.event.pull_request.number }} | |
REPO: ${{ github.repository }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
# Fetch details about the original comment | |
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 using bash string manipulation | |
COMMIT_ID=$(echo "$COMMENT_DATA" | tr ',' '\n' | grep '"commit_id"' | cut -d '"' -f 4) | |
PATH=$(echo "$COMMENT_DATA" | tr ',' '\n' | grep '"path"' | cut -d '"' -f 4) | |
POSITION=$(echo "$COMMENT_DATA" | tr ',' '\n' | grep '"position"' | cut -d ':' -f 2 | tr -d ' ') | |
# 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_REQUEST_NUMBER/comments \ | |
-d "{\"body\": \"Thanks for your reply!\", \"commit_id\": \"$COMMIT_ID\", \"path\": \"$PATH\", \"position\": $POSITION}" |