Skip to content

Commit 4ad22bf

Browse files
authored
Merge pull request DeusData#2798 from DeusData/fix/pr-ack-strip-hidden-note
fix(ci): post the PR acknowledgement without its hidden maintainer note
2 parents 31ba586 + 282f0e6 commit 4ad22bf

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

‎.github/workflows/pr-acknowledgement.yml‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,25 @@ jobs:
5151
run: |
5252
set -euo pipefail
5353
MESSAGE_FILE=.github/pr-acknowledgement.md
54+
BODY_FILE="$RUNNER_TEMP/pr-acknowledgement-body.md"
5455

5556
if [ ! -f "$MESSAGE_FILE" ]; then
5657
echo "No $MESSAGE_FILE in the base tree — acknowledgements are off."
5758
exit 0
5859
fi
5960

60-
# An empty or whitespace-only file is the documented off switch.
61-
if [ -z "$(tr -d '[:space:]' < "$MESSAGE_FILE")" ]; then
62-
echo "$MESSAGE_FILE is blank — acknowledgements are off."
61+
# HTML comments in the template are notes for maintainers. Posted
62+
# verbatim they become text a reader cannot see but a tool can, and
63+
# our own PR screening holds every comment that carries hidden text.
64+
# Strip them (an unterminated one runs to the end, as GitHub renders
65+
# it) so the posted body is exactly what the contributor sees.
66+
perl -0777 -pe 's/<!--.*?(?:-->|\z)[ \t]*\n?//gs' "$MESSAGE_FILE" > "$BODY_FILE"
67+
68+
# A body with no visible text is the documented off switch.
69+
if [ -z "$(tr -d '[:space:]' < "$BODY_FILE")" ]; then
70+
echo "$MESSAGE_FILE has no visible text — acknowledgements are off."
6371
exit 0
6472
fi
6573

66-
gh pr comment "$PR_NUMBER" --repo "$REPO" --body-file "$MESSAGE_FILE"
74+
gh pr comment "$PR_NUMBER" --repo "$REPO" --body-file "$BODY_FILE"
6775
echo "Acknowledged PR #${PR_NUMBER}."

0 commit comments

Comments
 (0)