-
Notifications
You must be signed in to change notification settings - Fork 0
85 lines (74 loc) · 3.08 KB
/
check_pr_release_notes.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#
# Copyright 2023 ABSA Group Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
name: Check Release Notes in PR description
on:
pull_request:
types: [opened, synchronize, reopened, edited, labeled, unlabeled]
branches: [ master ]
jobs:
check-release-notes:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get Pull Request Info
id: pr_info
uses: actions/github-script@v7
with:
script: |
const pr_number = context.payload.pull_request.number;
const pr = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: pr_number
});
const labels = pr.data.labels ? pr.data.labels.map(label => label.name) : [];
// Check if "skip-release-notes-check" label is present
if (labels.includes("skip-release-notes-check")) {
console.log("Skipping release notes check because 'skip-release-notes-check' label is present.");
core.setOutput("skip_check", 'true');
return;
}
const pr_body = pr.data.body;
if (!pr_body) {
core.setFailed("Pull request description is empty.");
core.setOutput("pr_body", "");
core.setOutput("skip_check", 'false');
return;
}
core.setOutput("pr_body", pr_body);
core.setOutput("skip_check", 'false');
return;
- name: Skip check if 'no-release-notes' label is present
if: steps.pr_info.outputs.skip_check == 'true'
run: echo "Skipping release notes validation."
- name: Check for 'Release notes:' and bullet list
if: steps.pr_info.outputs.skip_check == 'false'
run: |
# Extract the body from the previous step
PR_BODY="${{ steps.pr_info.outputs.pr_body }}"
# Check if "Release notes:" exists
if ! echo "$PR_BODY" | grep -qi 'release notes:'; then
echo "Error: 'Release notes:' not found in pull request description."
exit 1
fi
# Extract text after "Release notes:" line
RELEASE_NOTES=$(echo "$PR_BODY" | sed -n '/[Rr]elease.*[Nn]otes/,$p' | tail -n +2)
# Check if there's a bullet list (lines starting with '-' or '*')
if ! echo "$RELEASE_NOTES" | grep -qE '^\s*[-*]\s+.+$'; then
echo "Error: No bullet list found under 'Release notes:'."
exit 1
fi