Skip to content

Commit 020ded2

Browse files
authored
Deploy action: validate-new-issue.yml (#845)
1 parent ab5b867 commit 020ded2

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

.github/workflows/validate-new-issue.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff 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
@@ -48,8 +57,5 @@ jobs:
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 }}

0 commit comments

Comments
 (0)