2022-03-03 14:12:29 +01:00
name : Lint new PR
2021-03-01 21:28:53 +01:00
on :
pull_request :
2023-09-27 10:06:46 +02:00
types : [ opened, ready_for_review]
2021-03-01 21:28:53 +01:00
jobs :
check-description :
name : Check that PR has description
runs-on : ubuntu-20.04
2023-09-27 10:06:46 +02:00
if : github.event.pull_request.draft == false
2021-03-30 18:15:42 +02:00
2021-03-01 21:28:53 +01:00
steps :
2021-03-04 08:55:20 +01:00
- name : Check if PR is shame-worthy
2021-03-01 21:28:53 +01:00
id : is-shame-worthy
run : |
FILTERED_BODY=$( \
sed -r -e \
2024-01-19 14:15:17 +01:00
'/^(\.\.\.)|(\*)|(#+ )|(<!--)|(👉)/d' \
2021-03-01 21:28:53 +01:00
<<< $RAW_BODY \
)
echo "::debug::Filtered PR body to $FILTERED_BODY"
if [[ -z "${FILTERED_BODY//[[:space:]]/}" ]]; then
2022-10-26 19:28:12 +02:00
echo "is-shame-worthy=true" >> $GITHUB_OUTPUT
2021-03-01 21:28:53 +01:00
else
2022-10-26 19:28:12 +02:00
echo "is-shame-worthy=false" >> $GITHUB_OUTPUT
2021-03-01 21:28:53 +01:00
fi
env :
RAW_BODY : ${{ github.event.pull_request.body }}
- name : Shame if PR has no description
if : steps.is-shame-worthy.outputs.is-shame-worthy == 'true'
run : |
2021-03-04 08:55:20 +01:00
SHAME_BODY="Hey @${{ github.actor }}! 👋\nThis pull request seems to contain no description. Please add useful context, rationale, and/or any other information that will help make sense of this change now and in the distant Mars-based future."
2021-06-17 00:22:23 +02:00
curl -s -u posthog-bot:${{ secrets.POSTHOG_BOT_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} -X POST -d "{ \"body\": \"$SHAME_BODY\" }" "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments"