From b460d2f781e51c137e00d75555be2202d752f1a3 Mon Sep 17 00:00:00 2001 From: Kristian Date: Wed, 7 Oct 2026 20:07:40 +0200 Subject: [PATCH] Have CI check that the changelog line ends with the pull request's number --- .github/workflows/ci.yml | 9 ++++++--- CHANGELOG.md | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a720098..901adc8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,8 +24,11 @@ jobs: - name: Changelog entry if: github.event_name == 'pull_request' run: | - if git diff --quiet "origin/${{ github.base_ref }}...HEAD" -- CHANGELOG.md; then - echo "CHANGELOG.md was not changed by this pull request." - echo "Every pull request adds a line under Unreleased in CHANGELOG.md that says what it changes." + number="${{ github.event.pull_request.number }}" + added=$(git diff "origin/${{ github.base_ref }}...HEAD" -- CHANGELOG.md | grep -E '^\+[^+]' || true) + if ! echo "$added" | grep -qE "\(#${number}\)[[:space:]]*$"; then + echo "CHANGELOG.md has no new line that ends with this pull request's number, (#${number})." + echo "Every pull request adds a line under Unreleased in CHANGELOG.md that says what it changes" + echo "and ends with its own number, for example: - \`GET /tasks\` lists the tasks. (#${number})" exit 1 fi diff --git a/CHANGELOG.md b/CHANGELOG.md index d929b82..7a7e5d4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,4 +6,4 @@ what it changes for someone who uses the API. CI checks that it did. ## Unreleased - `GET /tasks/count` says how many tasks there are, and how many are done. -- CI checks that a pull request adds a line here. +- CI checks that a pull request adds a line here that ends with its number. (#4)