Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/workflows/towncrier-run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ on:
default: "ubuntu-latest"
type: string

permissions:
pull-requests: write

defaults:
run:
shell: bash
Expand Down Expand Up @@ -71,6 +74,25 @@ jobs:
id: tox
run: tox -e towncrier-check

- 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! 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/).

<!-- towncrier-missing-change-note -->"

COMMENTS=$(gh api repos/${{ github.repository }}/issues/${PR_NUM}/comments)
HAS_COMMENT=$(jq -r '.[] | select(.body | contains("<!-- towncrier-missing-change-note -->")) | .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: |
Expand Down
Loading