Skip to content

#92 - Add support for more characters as markdown list rows #38

#92 - Add support for more characters as markdown list rows

#92 - Add support for more characters as markdown list rows #38

#
# 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 'skip-release-notes-check' 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 -q '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 '/Release.*Notes/,$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