File tree Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -26,16 +26,25 @@ jobs:
2626 # - extra headings in the issue are fine
2727 # - order doesn't matter
2828 # - case-sensitive tho
29+ # - can't post a template unchanged (ignoring whitespace)
2930 function extract-headings { { grep '^#' "$1" || echo -n ''; } | sort; }
30- extract-headings <(jq -r .issue.body "$GITHUB_EVENT_PATH") > headings-in-issue
31+ jq -r .issue.body "$GITHUB_EVENT_PATH" > issue
32+ extract-headings <(cat issue) > headings-in-issue
3133 for template in $(ls .github/ISSUE_TEMPLATE/*.md 2> /dev/null); do
34+ # Strip front matter. https://stackoverflow.com/a/29292490/14946704
35+ sed -i'' '1{/^---$/!q;};1,/^---$/d' "$template"
3236 extract-headings "$template" > headings-in-template
3337 echo -n "$(basename $template)? "
3438 if [ ! -s headings-in-template ]; then
3539 echo "No headers in template. 🤷"
3640 elif [ -z "$(comm -23 headings-in-template headings-in-issue)" ]; then
3741 echo "Match! 👍 💃"
38- exit 0
42+ if diff -Bw "$template" issue > /dev/null; then
43+ echo "... like, an /exact/ match. 😖"
44+ break
45+ else
46+ exit 0
47+ fi
3948 else
4049 echo "No match. 👎"
4150 fi
4857
4958 # Might get `gh issue comment` some day - https://github.com/cli/cli/issues/517
5059 echo -n "Commented: "
51- gh api "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/comments" \
52- --method POST \
53- --input comment \
54- | jq .html_url
60+ gh issue comment ${{ github.event.issue.number }} --body "$(cat comment)"
5561 gh issue close ${{ github.event.issue.number }}
You can’t perform that action at this time.
0 commit comments