mirror of
https://github.com/github/codeql.git
synced 2026-01-07 19:50:22 +01:00
Distinguish between validated and raw COMMENT_ID
This commit is contained in:
8
.github/workflows/post-pr-comment.yml
vendored
8
.github/workflows/post-pr-comment.yml
vendored
@@ -45,9 +45,9 @@ jobs:
|
||||
# If there is no existing comment, comment_id.txt will contain just a
|
||||
# newline (due to jq & gh behaviour). This will cause grep to fail, so
|
||||
# we catch that.
|
||||
COMMENT_ID=$(grep -o '^[0-9]\+$' comment_id.txt || true)
|
||||
RAW_COMMENT_ID=$(grep -o '^[0-9]\+$' comment_id.txt || true)
|
||||
|
||||
if [ $COMMENT_ID ]
|
||||
if [ $RAW_COMMENT_ID ]
|
||||
then
|
||||
# Fetch existing comment, and validate:
|
||||
# - comment belongs to the PR with number $PR_NUMBER
|
||||
@@ -57,13 +57,13 @@ jobs:
|
||||
| select(.body | test(\"^${COMMENT_PREFIX}\")) \
|
||||
| select(.user.login == \"${COMMENT_AUTHOR}\") \
|
||||
| .id"
|
||||
COMMENT_ID=$(gh api "repos/${GITHUB_REPOSITORY}/issues/comments/${COMMENT_ID}" | jq "${FILTER}")
|
||||
COMMENT_ID=$(gh api "repos/${GITHUB_REPOSITORY}/issues/comments/${RAW_COMMENT_ID}" | jq "${FILTER}")
|
||||
if [ $COMMENT_ID ]
|
||||
then
|
||||
# Update existing comment
|
||||
jq --rawfile body comment_body.txt '{"body":$body}' -n | gh api "repos/${GITHUB_REPOSITORY}/issues/comments/${COMMENT_ID}" -X PATCH --input -
|
||||
else
|
||||
echo "Comment ${COMMENT_ID} did not pass validations: not editing."
|
||||
echo "Comment ${RAW_COMMENT_ID} did not pass validations: not editing."
|
||||
fi
|
||||
else
|
||||
# Create new comment
|
||||
|
||||
Reference in New Issue
Block a user