Skip to content

Commit c9a5cb4

Browse files
committed
Distinguish between validated and raw COMMENT_ID
1 parent 1df1f42 commit c9a5cb4

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

.github/workflows/post-pr-comment.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ jobs:
4545
# If there is no existing comment, comment_id.txt will contain just a
4646
# newline (due to jq & gh behaviour). This will cause grep to fail, so
4747
# we catch that.
48-
COMMENT_ID=$(grep -o '^[0-9]\+$' comment_id.txt || true)
48+
RAW_COMMENT_ID=$(grep -o '^[0-9]\+$' comment_id.txt || true)
4949
50-
if [ $COMMENT_ID ]
50+
if [ $RAW_COMMENT_ID ]
5151
then
5252
# Fetch existing comment, and validate:
5353
# - comment belongs to the PR with number $PR_NUMBER
@@ -57,13 +57,13 @@ jobs:
5757
| select(.body | test(\"^${COMMENT_PREFIX}\")) \
5858
| select(.user.login == \"${COMMENT_AUTHOR}\") \
5959
| .id"
60-
COMMENT_ID=$(gh api "repos/${GITHUB_REPOSITORY}/issues/comments/${COMMENT_ID}" | jq "${FILTER}")
60+
COMMENT_ID=$(gh api "repos/${GITHUB_REPOSITORY}/issues/comments/${RAW_COMMENT_ID}" | jq "${FILTER}")
6161
if [ $COMMENT_ID ]
6262
then
6363
# Update existing comment
6464
jq --rawfile body comment_body.txt '{"body":$body}' -n | gh api "repos/${GITHUB_REPOSITORY}/issues/comments/${COMMENT_ID}" -X PATCH --input -
6565
else
66-
echo "Comment ${COMMENT_ID} did not pass validations: not editing."
66+
echo "Comment ${RAW_COMMENT_ID} did not pass validations: not editing."
6767
fi
6868
else
6969
# Create new comment

0 commit comments

Comments
 (0)