Skip to content

Commit 745704d

Browse files
committed
ci: Require changelog description
Any PR that is labeled with any `impact/*` label should have a description for the changelog and an `area/*` label. (copied from moby/moby 1d473549e865ef6b90ee936c280f4bda677de39b) Signed-off-by: Paweł Gronowski <[email protected]>
1 parent b982833 commit 745704d

File tree

2 files changed

+51
-1
lines changed

2 files changed

+51
-1
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,13 @@ Please provide the following information:
2222
**- Description for the changelog**
2323
<!--
2424
Write a short (one line) summary that describes the changes in this
25-
pull request for inclusion in the changelog:
25+
pull request for inclusion in the changelog.
26+
It must be placed inside the below triple backticks section:
2627
-->
28+
```markdown changelog
2729

2830

31+
```
32+
2933
**- A picture of a cute animal (not mandatory but encouraged)**
3034

.github/workflows/validate-pr.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: validate-pr
2+
3+
on:
4+
pull_request:
5+
types: [opened, edited, labeled, unlabeled]
6+
7+
jobs:
8+
check-area-label:
9+
runs-on: ubuntu-20.04
10+
steps:
11+
- name: Missing `area/` label
12+
if: contains(join(github.event.pull_request.labels.*.name, ','), 'impact/') && !contains(join(github.event.pull_request.labels.*.name, ','), 'area/')
13+
run: |
14+
echo "Every PR with an \`impact/*\` label should also have an \`area/*\` label"
15+
exit 1
16+
- name: OK
17+
run: exit 0
18+
19+
check-changelog:
20+
if: contains(join(github.event.pull_request.labels.*.name, ','), 'impact/')
21+
runs-on: ubuntu-20.04
22+
env:
23+
PR_BODY: |
24+
${{ github.event.pull_request.body }}
25+
steps:
26+
- name: Check changelog description
27+
run: |
28+
# Extract the `markdown changelog` note code block
29+
block=$(echo -n "$PR_BODY" | tr -d '\r' | awk '/^```markdown changelog$/{flag=1;next}/^```$/{flag=0}flag')
30+
31+
# Strip empty lines
32+
desc=$(echo "$block" | awk NF)
33+
34+
if [ -z "$desc" ]; then
35+
echo "Changelog section is empty. Please provide a description for the changelog."
36+
exit 1
37+
fi
38+
39+
len=$(echo -n "$desc" | wc -c)
40+
if [[ $len -le 6 ]]; then
41+
echo "Description looks too short: $desc"
42+
exit 1
43+
fi
44+
45+
echo "This PR will be included in the release notes with the following note:"
46+
echo "$desc"

0 commit comments

Comments
 (0)