Skip to content

Commit

Permalink
Update markdown_issue_check.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
Staubgeborener authored Sep 18, 2024
1 parent 442de12 commit 35a26f1
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions .github/workflows/markdown_issue_check.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Check for markdown code blocks in issues
name: Check for Markdown code blocks in Issues

on:
issues:
Expand All @@ -21,6 +21,7 @@ jobs:
# Check if the issue body contains Markdown inline code or code block (`` ` ``)
if echo "$ISSUE_BODY" | grep -q "\`"; then
echo "Markdown code detected."
echo "markdown_used=true" >> $GITHUB_ENV
else
echo "No Markdown code detected."
echo "markdown_used=false" >> $GITHUB_ENV
Expand All @@ -31,12 +32,16 @@ jobs:
run: |
ISSUE_NUMBER="${{ github.event.issue.number }}"
REPO="${{ github.repository }}"
# Define COMMENT_BODY with backticks directly
COMMENT_BODY="Please use markdown syntax (``) for code snippets in your issue. You have confirmed the checkbox that you are using markdown, but none was recognized here. The markdown syntax makes your issue more readable and makes it easier to find a solution to your problem more quickly.\\n\\nExamples:\nThe symbol ` turns `code` into \`code\`.\\n\\nFor more code use ` three times at the beginning and at the end like this:\\n```\\nsome\\ncode\\n```\\nturns into:\\n\`\`\`\\nsome\\ncode\\n\`\`\`\\nPlease edit your outgoing post immediately. If you think that this hint is not necessary and you have correctly used markdown, then you can simply ignore this message."
# Escape special characters in COMMENT_BODY
ESCAPED_COMMENT_BODY=$(echo "$COMMENT_BODY" | sed 's/[&"]/\\&/g')
# Post a comment on the issue
curl -s -X POST \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: application/json" \
-d "{\"body\":\"${COMMENT_BODY}\"}" \
-d "{\"body\":\"${ESCAPED_COMMENT_BODY}\"}" \
"https://api.github.com/repos/${REPO}/issues/${ISSUE_NUMBER}/comments"

0 comments on commit 35a26f1

Please sign in to comment.