From 32093e3841d9d8bd4958b28ee28c60d1c7b86aff Mon Sep 17 00:00:00 2001 From: ijbo Date: Thu, 14 May 2026 19:39:59 +0900 Subject: [PATCH] ci: exclude deleted files from changelog-location check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The check-changelog job in deploy.yml flagged any path matching ^CHANGELOG-.*\.md$ in the diff — including pure deletions. Commits that moved a root-level changelog into changelogs/ or removed duplicates still failed the gate, since the old root path appeared in git diff --name-only as a deletion entry. Fix: pass --diff-filter=ACMR so the file list only contains files that were Added, Copied, Modified, or Renamed — deletions are ignored. Newly-added root-level CHANGELOG-*.md files are still caught. --- .github/workflows/deploy.yml | 13 +++++++----- changelogs/CHANGELOG-ci-changelog-check.md | 24 ++++++++++++++++++++++ 2 files changed, 32 insertions(+), 5 deletions(-) create mode 100644 changelogs/CHANGELOG-ci-changelog-check.md diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index e970a2f..f0745f8 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -26,14 +26,16 @@ jobs: - name: Check for CHANGELOG file in commit run: | - # Get files changed in this push/PR + # Get files changed in this push/PR. + # Use --diff-filter=ACMR so deletions don't count — removing a file + # shouldn't fail a rule that's checking for file presence. if [ "${{ github.event_name }}" = "pull_request" ]; then - FILES=$(git diff --name-only HEAD~1 HEAD 2>/dev/null || git diff --name-only ${{ github.event.pull_request.base.sha }} HEAD) + FILES=$(git diff --name-only --diff-filter=ACMR HEAD~1 HEAD 2>/dev/null || git diff --name-only --diff-filter=ACMR ${{ github.event.pull_request.base.sha }} HEAD) else - FILES=$(git diff --name-only HEAD~1 HEAD) + FILES=$(git diff --name-only --diff-filter=ACMR HEAD~1 HEAD) fi - echo "Changed files:" + echo "Changed files (added/modified/copied/renamed):" echo "$FILES" # Check if any code files changed (ignore docs-only) @@ -44,7 +46,8 @@ jobs: exit 0 fi - # Reject changelogs placed in repo root instead of changelogs/ + # Reject changelogs placed in repo root instead of changelogs/. + # Only checks added/modified files (see --diff-filter above); pure deletions are allowed. ROOT_CHANGELOG=$(echo "$FILES" | grep -E '^CHANGELOG-.*\.md$' || true) if [ -n "$ROOT_CHANGELOG" ]; then echo "" diff --git a/changelogs/CHANGELOG-ci-changelog-check.md b/changelogs/CHANGELOG-ci-changelog-check.md new file mode 100644 index 0000000..00333f0 --- /dev/null +++ b/changelogs/CHANGELOG-ci-changelog-check.md @@ -0,0 +1,24 @@ +# CI — Exclude Deletions from Changelog-Location Check + +- Added `--diff-filter=ACMR` to both `git diff --name-only` invocations in the `check-changelog` job of `.github/workflows/deploy.yml` +- The job now only inspects Added / Copied / Modified / Renamed paths; pure deletions are ignored + +--- + +## Summary +The `check-changelog` CI gate was firing on commits that **removed** a root-level `CHANGELOG-*.md` file. Because `git diff --name-only` returns the path of a file regardless of whether it was added, modified, or deleted, the regex `^CHANGELOG-.*\.md$` matched the deleted root-level changelog and the job failed with `❌ FAILED: Changelog found in repo root`. + +This meant any legitimate cleanup commit that moved a stray root changelog into `changelogs/` (or removed an identical duplicate) would be blocked — the very kind of fix the rule wants to encourage. + +## 1. Workflow Fix +**Files:** `.github/workflows/deploy.yml` +**What:** Both `git diff` calls in the `check-changelog` step now pass `--diff-filter=ACMR`, restricting the file list to Added / Copied / Modified / Renamed entries. Deletions are excluded. +**Impact:** Cleanup commits that remove or move root-level changelogs into `changelogs/` no longer fail the gate. New violations (a fresh `CHANGELOG-*.md` added at the repo root) are still caught, because added files are kept in the filter. + +--- + +## Files Changed (1 total) + +| File | Lines Changed | Type | +|------|:---:|------| +| `.github/workflows/deploy.yml` | +8 −5 | Added `--diff-filter=ACMR` and updated step comment |