Test pr automation #206
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Check PR for Changelog | |
on: | |
push: | |
pull_request: | |
types: [opened, edited, reopened] | |
jobs: | |
check-description: | |
runs-on: ubuntu-latest | |
if: github.event_name == 'pull_request' | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Check PR Description | |
id: check_description | |
run: | | |
description=$(jq -r ".pull_request.body" "$GITHUB_EVENT_PATH" | awk '/## Changelog/{flag=1; next} /##/{flag=0} flag' | grep -oP '(?<=- \*\*Description:\*\* ).*' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//') | |
echo "$description" | |
default_description="Summary of change(s)" | |
if [ -n "$description" ] && [ "$description" != "$default_description" ]; then | |
echo "containsChangelog=true" >> $GITHUB_OUTPUT | |
else | |
echo "containsChangelog=false" >> $GITHUB_OUTPUT | |
fi | |
- name: Results | |
run: | | |
if [[ "${{ steps.check_description.outputs.containsChangelog }}" == "true" || "${{ github.event.pull_request.user.login }}" == "dependabot[bot]" ]]; then | |
echo "PR contains Changelog section/ PR made by Dependabot" | |
exit 0 | |
else | |
echo "Changelog section is missing or does not contain the required details" | |
exit 1 | |
fi |