diff --git a/.github/workflows/check_release_notes.yml b/.github/workflows/check_release_notes.yml index a9718eb..782a0fb 100644 --- a/.github/workflows/check_release_notes.yml +++ b/.github/workflows/check_release_notes.yml @@ -8,7 +8,7 @@ name: Labeler on: pull_request: - types: [labeled, unlabeled] + types: [labeled, unlabeled, edited] jobs: label: @@ -25,4 +25,7 @@ jobs: - name: Dump GitHub context env: GITHUB_CONTEXT: ${{ toJSON(github) }} - run: echo "$GITHUB_CONTEXT" \ No newline at end of file + run: echo "$GITHUB_CONTEXT" + - name: Get env + id: pr-info + run: env \ No newline at end of file diff --git a/check_release_notes.py b/check_release_notes.py new file mode 100644 index 0000000..5fdec2b --- /dev/null +++ b/check_release_notes.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python3 + +import re +import sys +import json + +input_data = json.loads(sys.stdin.read()) +pr_body = input_data['body'] + +if result := re.search("(?<=```release-note\n).*?(?=\n```)", pr_body, re.DOTALL): + release_note = result.group().strip() + if not release_note: + print('FAIL: Release note is empty', file=sys.stderr) + sys.exit(-1) + if release_note.lower() == "tbd": + print('FAIL: Release note contains "TBD"', file=sys.stderr) + sys.exit(-1) +else: + print('FAIL: No release notes found in PR body', file=sys.stderr) + sys.exit(-1) + +sys.exit(0) \ No newline at end of file