From 8a2e0e5cf3b6969b2c68e1c9b5d65e864ebfe7ef Mon Sep 17 00:00:00 2001 From: Lars Toenning Date: Sun, 28 Jun 2026 12:34:20 +0200 Subject: [PATCH] ci: Add check for modification of changelog --- .github/workflows/build.yml | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 91be22e59..9ec56d4d1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -59,12 +59,45 @@ jobs: checks: runs-on: ubuntu-22.04 needs: preBuild + permissions: + pull-requests: read + contents: read steps: - name: Checkout repository uses: actions/checkout@v6 with: fetch-depth: '0' + - name: Check for CHANGELOG or no-changelog label + if: github.event_name == 'pull_request' + env: + GH_TOKEN: ${{ github.token }} + run: | + set -e + + BASE_SHA="${{ github.event.pull_request.base.sha }}" + HEAD_SHA="${{ github.event.pull_request.head.sha }}" + + echo "Checking changed files..." + + if git diff --name-only "$BASE_SHA" "$HEAD_SHA" | grep -qx "CHANGELOG.md"; then + echo "✅ CHANGELOG.md was modified." + exit 0 + fi + + echo "CHANGELOG.md not modified. Checking labels..." + + LABELS=$(gh api \ + repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/labels \ + --jq '.[].name') + + if echo "$LABELS" | grep -qx "no-changelog"; then + echo "✅ no-changelog label found." + exit 0 + fi + + echo "::error::This PR must either modify CHANGELOG.md or have the 'no-changelog' label." + exit 1 - name: Install gitlint run: | pip install gitlint==0.19.1