@@ -39,14 +39,48 @@ jobs:
3939 PR_BODY : ${{ github.event.pull_request.body }}
4040 PR_LABELS : ${{ toJson(github.event.pull_request.labels) }}
4141 run : |
42- echo "Pull Request Labels: $PR_LABELS"
43- echo "Pull Request Body: $PR_BODY"
44-
4542 # Check if "breaking" label is set
4643 if echo "$PR_LABELS" | grep -q '"breaking"'; then
4744 echo "Label 'breaking' is present. Checking description..."
4845 if echo "$PR_BODY" | grep -qi "## ⚠️ Breaking Changes ⚠️"; then
49- echo "✅ Description contains the required phrase."
46+ echo "✅ Description contains the required '## ⚠️ Breaking Changes ⚠️' heading."
47+
48+ echo "Extracting 'Breaking Changes' section for structural validation..."
49+ BREAKING_SECTION="$(
50+ printf '%s\n' "$PR_BODY" | awk '
51+ BEGIN { flag=0 }
52+ /^##[[:space:]]*⚠️[[:space:]]*Breaking[[:space:]]*Changes[[:space:]]*⚠️/ { flag=1; next }
53+ /^##[[:space:]]+/ && flag==1 { flag=0 }
54+ flag==1 { print }
55+ '
56+ )"
57+
58+ if [ -z "$BREAKING_SECTION" ]; then
59+ echo "❌ Could not extract content under the '## ⚠️ Breaking Changes ⚠️' heading."
60+ echo " Please ensure there is content under this heading describing the breaking change."
61+ exit 1
62+ fi
63+
64+ echo "Validating required structure inside 'Breaking Changes' section..."
65+
66+ # Require the three key bullets in the example template:
67+ # - **Short description**
68+ # - **Who is affected**
69+ # - **Suggested code changes**
70+ REQUIRED_ITEMS=("Short description" "Who is affected" "Suggested code changes")
71+
72+ for item in "${REQUIRED_ITEMS[@]}"; do
73+ if ! printf '%s\n' "$BREAKING_SECTION" | grep -qiE "^[[:space:]]*-[[:space:]]+\*\*$item\*\*"; then
74+ echo "❌ 'Breaking Changes' section must contain a bullet heading '**$item**'."
75+ echo " Please follow the template:"
76+ echo " - **Short description**"
77+ echo " - **Who is affected**"
78+ echo " - **Suggested code changes**"
79+ exit 1
80+ fi
81+ done
82+
83+ echo "✅ 'Breaking Changes' section has the required structure."
5084 else
5185 echo "❌ Description does not contain the required phrase '## ⚠️ Breaking Changes ⚠️'."
5286 exit 1
0 commit comments