-
Notifications
You must be signed in to change notification settings - Fork 125
33 lines (30 loc) · 1.49 KB
/
new-pr.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
name: New PR
on:
pull_request:
types: [opened]
jobs:
check-description:
name: Check that PR has description
runs-on: ubuntu-20.04
steps:
- name: Check if PR is shame-worthy
id: is-shame-worthy
run: |
FILTERED_BODY=$( \
sed -r -e \
'/^(\.\.\.)|(\*)|(##? )|(- \[)/d' \
<<< $RAW_BODY \
)
echo "::debug::Filtered PR body to $FILTERED_BODY"
if [[ -z "${FILTERED_BODY//[[:space:]]/}" ]]; then
echo "is-shame-worthy=true" >> "$GITHUB_OUTPUT"
else
echo "is-shame-worthy=false" >> "$GITHUB_OUTPUT"
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: |
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."
curl -s -u posthog-bot:${{ secrets.POSTHOG_BOT_GITHUB_TOKEN }} -X POST -d "{ \"body\": \"$SHAME_BODY\" }" "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments"