From 6e4d3fb63d9c4d75040616dcdf7c77fadc4ef827 Mon Sep 17 00:00:00 2001 From: Mario Campos Date: Thu, 8 Oct 2026 12:31:10 -0500 Subject: [PATCH] Use a sticky comment to warn about CHANGELOG.md changes --- .github/workflows/pr-checks.yml | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pr-checks.yml b/.github/workflows/pr-checks.yml index 3c0394328..9121b16e2 100644 --- a/.github/workflows/pr-checks.yml +++ b/.github/workflows/pr-checks.yml @@ -282,11 +282,25 @@ jobs: startsWith(github.event.pull_request.head.ref, 'update-bundle/') ) env: + COMMENT_MARKER: "" GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} PR_NUMBER: ${{ github.event.pull_request.number }} run: | - body="⚠️ CHANGELOG.md was modified in this PR. Please do not modify CHANGELOG.md directly. \ - Instead, describe your change as a change-note. The CHANGELOG.md file will be automatically \ - generated from change-notes. For more information, \ + comment_id=$( + gh api "repos/$GITHUB_REPOSITORY/issues/$PR_NUMBER/comments" \ + --paginate \ + --jq ".[] | select(.body | contains(\"$COMMENT_MARKER\")) | .id" \ + | head -n 1 + ) + + if [[ -n "$comment_id" ]]; then + echo "CHANGELOG.md warning comment already exists ($comment_id)." + exit 0 + fi + + body="$COMMENT_MARKER + ⚠️ CHANGELOG.md was modified in this PR. Please do not modify CHANGELOG.md directly. + Instead, describe your change as a change-note. The CHANGELOG.md file will be automatically + generated from change-notes. For more information, see [CONTRIBUTING.md](https://github.com/github/codeql-action/blob/main/CONTRIBUTING.md)." gh api --method POST "repos/$GITHUB_REPOSITORY/issues/$PR_NUMBER/comments" --field body="$body"