Skip to content

Warn on missing "Change log entry" section #2

Warn on missing "Change log entry" section

Warn on missing "Change log entry" section #2

name: Ensure CHANGELOG entry in pull request description
on:
pull_request:
types: [opened, reopened, edited]
jobs:
ensure_changelog_entry:
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Find changelog entry
uses: actions/github-script@v7
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const body = context.payload.pull_request.body
# Groups: yes - 1, entry - 2, no - 3
const regex = /\*\*CHANGELOG entry\*\*\s+(?:(yes|yeah)(?:\.\s*(.*))?|(no|nope|none)\.?)\s*(?:\*\*Additional Notes|\*\*How to test|\z)/mi
matches = body.match()
if (undefined == matches.at(1) || undefined == matches.at(3)) {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: ${{ github.event.pull_request.number }},
`Please fill CHANGELOG entry section.
If your changes need mention in a CHANGELOG
> Yes. <brief summary to be placed into the change log>
or as follows if they don't
> No.
`,
})
}