-
Notifications
You must be signed in to change notification settings - Fork 320
56 lines (51 loc) · 2.01 KB
/
pr-desc-lint.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
name: PR Description Check
on:
pull_request:
branches:
- develop
- main
types:
- opened
- synchronize
- reopened
- edited
jobs:
check-description:
runs-on: macos-latest
steps:
- name: Install GitHub CLI
run: |
brew install gh
- name: Check PR Description
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
pr_description=$(gh pr view https://github.com/${GITHUB_REPOSITORY}/pull/${{ github.event.pull_request.number }} --json body -q ".body")
error_occurred=0
# Define minimum character count for each section
MIN_CHARS=25
# Extract contents
# Extract contents
what_changed=$(echo "$pr_description" | sed -n -e '/\*What was changed?\*/,/\*/p' | sed '$d' | sed '1d')
why_changed=$(echo "$pr_description" | sed -n -e '/\*Why was it changed?\*/,/\*/p' | sed '$d' | sed '1d')
how_changed=$(echo "$pr_description" | sed -n -e '/\*How was it changed?\*/,/\*/p' | sed '$d' | sed '1d')
testing_done=$(echo "$pr_description" | sed -n -e '/\*What testing was done for the changes?\*/,/\*/p' | sed '$d' | sed '1d')
if [[ ${#what_changed} -lt $MIN_CHARS ]]; then
echo "PR description for what changed section is either missing or too short."
error_occurred=1
fi
if [[ ${#why_changed} -lt $MIN_CHARS ]]; then
echo "PR description for why it changed section is either missing or too short."
error_occurred=1
fi
if [[ ${#how_changed} -lt $MIN_CHARS ]]; then
echo "PR description for how was it changed section is either missing or too short."
error_occurred=1
fi
if [[ ${#testing_done} -lt $MIN_CHARS ]]; then
echo "PR description for testing section are either missing or too short."
error_occurred=1
fi
if [[ $error_occurred -eq 1 ]]; then
exit 1
fi