From b331d0a4b8c5e2e66e8659694d960c4bb2963863 Mon Sep 17 00:00:00 2001 From: Andy Fundinger Date: Tue, 19 May 2026 19:37:55 -0400 Subject: [PATCH 1/3] Add feature for towncrier-run.yml to comment on PR when it fails. --- .github/workflows/towncrier-run.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/.github/workflows/towncrier-run.yml b/.github/workflows/towncrier-run.yml index 7e1dd1d..4f7b642 100644 --- a/.github/workflows/towncrier-run.yml +++ b/.github/workflows/towncrier-run.yml @@ -24,6 +24,9 @@ on: default: "ubuntu-latest" type: string +permissions: + pull-requests: write + defaults: run: shell: bash @@ -71,6 +74,25 @@ jobs: id: tox run: tox -e towncrier-check + - name: Comment PR for Missing Change Note + if: always() && github.event_name == 'pull_request' && steps.tox.outcome == 'failure' + env: + GITHUB_TOKEN: ${{ github.token }} + PR_NUM: ${{ github.event.pull_request.number }} + run: | + MESSAGE="The Towncrier check failed because a change note is missing from the \`changes\` directory. Please visit the BeeWare Contribution Guide to learn how to add a change note for this PR: https://beeware.org/contributing/guide/how/change-note/ + + " + + COMMENTS=$(gh api repos/${{ github.repository }}/issues/${PR_NUM}/comments) + HAS_COMMENT=$(jq -r '.[] | select(.body | contains("")) | .body' <<< "$COMMENTS") + + if [ -z "$HAS_COMMENT" ]; then + gh api --method POST repos/${{ github.repository }}/issues/${PR_NUM}/comments -f body="$MESSAGE" + else + echo "Comment already exists." + fi + - name: Towncrier Check Resolution Instructions if: always() && steps.tox.outcome == 'failure' run: | From 0d6ba50700ad68b300938454236cab743677b665 Mon Sep 17 00:00:00 2001 From: Andy Fundinger Date: Tue, 19 May 2026 20:29:46 -0400 Subject: [PATCH 2/3] Revising message for better tone. --- .github/workflows/towncrier-run.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/towncrier-run.yml b/.github/workflows/towncrier-run.yml index 4f7b642..fd5baa9 100644 --- a/.github/workflows/towncrier-run.yml +++ b/.github/workflows/towncrier-run.yml @@ -80,7 +80,7 @@ jobs: GITHUB_TOKEN: ${{ github.token }} PR_NUM: ${{ github.event.pull_request.number }} run: | - MESSAGE="The Towncrier check failed because a change note is missing from the \`changes\` directory. Please visit the BeeWare Contribution Guide to learn how to add a change note for this PR: https://beeware.org/contributing/guide/how/change-note/ + MESSAGE="Thank you for your pull request! However, the Towncrier check failed because a change note is missing from the \`changes\` directory. Please visit the BeeWare Contribution Guide to learn how to add a change note for this PR: https://beeware.org/contributing/guide/how/change-note/ " From 2e8a86e2f6bf15a8a61cb4b28f3eb100999da797 Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Tue, 19 May 2026 20:41:37 -0700 Subject: [PATCH 3/3] Tweak town crier message text. --- .github/workflows/towncrier-run.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/towncrier-run.yml b/.github/workflows/towncrier-run.yml index fd5baa9..356209c 100644 --- a/.github/workflows/towncrier-run.yml +++ b/.github/workflows/towncrier-run.yml @@ -74,13 +74,13 @@ jobs: id: tox run: tox -e towncrier-check - - name: Comment PR for Missing Change Note + - name: Add PR comment if change note is missing if: always() && github.event_name == 'pull_request' && steps.tox.outcome == 'failure' env: GITHUB_TOKEN: ${{ github.token }} PR_NUM: ${{ github.event.pull_request.number }} run: | - MESSAGE="Thank you for your pull request! However, the Towncrier check failed because a change note is missing from the \`changes\` directory. Please visit the BeeWare Contribution Guide to learn how to add a change note for this PR: https://beeware.org/contributing/guide/how/change-note/ + MESSAGE="Thank you for your pull request! Unfortunately, CI checks for this pull request are failing because you haven't included a change note in your contribution. Details on creating a change note can be found in the [BeeWare Contribution Guide](https://beeware.org/contributing/guide/how/change-note/). "