diff --git a/.github/workflows/ci_changelog_check.yaml b/.github/workflows/ci_changelog_check.yaml new file mode 100644 index 00000000..cbbefa4d --- /dev/null +++ b/.github/workflows/ci_changelog_check.yaml @@ -0,0 +1,59 @@ +name: ci_changelog_check + +# Runs on every PR event that could change which files are included. +# 'labeled'/'unlabeled' are needed so that adding/removing the +# 'no-changelog' label immediately re-evaluates the check. +on: + pull_request: + branches: + - main + types: + - opened + - reopened + - synchronize + - labeled + - unlabeled + +permissions: + contents: read + pull-requests: read + +jobs: + changelog_check: + runs-on: ubuntu-latest + name: Check Changelog Entry + + # Skip the whole job (shows as "skipped" = passing) when a maintainer + # has deliberately labelled the PR 'no-changelog'. + # Typical use-cases: CI-only fixes, typo corrections, dependency bumps. + if: "!contains(github.event.pull_request.labels.*.name, 'no-changelog')" + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + # Full history is required so tj-actions/changed-files can compare + # the PR branch against the base branch correctly. + fetch-depth: 0 + + - name: Detect changed files + id: changed_files + uses: tj-actions/changed-files@v44 + with: + # Only care about the top-level CHANGELOG.md. + files: CHANGELOG.md + + - name: Fail — no changelog entry found + if: steps.changed_files.outputs.any_changed == 'false' + run: | + echo "::error file=CHANGELOG.md::Missing changelog entry. Please add one before merging." + echo "" + echo "Every user-facing pull request must include an update to CHANGELOG.md." + echo "If this PR genuinely does not need a changelog entry (e.g. a CI fix," + echo "a typo correction, or a dependency bump), ask a maintainer to add the" + echo "'no-changelog' label to skip this check." + exit 1 + + - name: Pass — changelog entry found + if: steps.changed_files.outputs.any_changed == 'true' + run: echo "CHANGELOG.md was updated. Check passed." diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f434c6b..e1075b54 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,3 +11,7 @@ Scribe-Android tries to follow [semantic versioning](https://semver.org/), a MAJ Emojis for the following are chosen based on [gitmoji](https://gitmoji.dev/). # Scribe-Android 1.0.0 + +### CI/CD + +- Added `ci_changelog_check` workflow to enforce `CHANGELOG.md` updates on all PRs targeting `main`, with support for a `no-changelog` label to skip the check when appropriate