diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml new file mode 100644 index 00000000..b9c4c6de --- /dev/null +++ b/.github/workflows/changelog.yml @@ -0,0 +1,30 @@ +name: Changelog + +on: + pull_request: + branches: [master] + types: [opened, synchronize, reopened, labeled, unlabeled] + +jobs: + has_changelog: + runs-on: ubuntu-latest + # Opt-out: PRs labeled 'No changelog' skip the check entirely + # (docs-only, dependency bumps, CI tweaks). + if: ${{ !contains(github.event.pull_request.labels.*.name, 'No changelog') }} + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Check that the PR adds a changelog entry + run: | + git fetch origin "${{ github.base_ref }}" + head_sha="${{ github.event.pull_request.head.sha || 'HEAD' }}" + changed="$(git diff --name-only "origin/${{ github.base_ref }}"..."$head_sha" -- changelog/)" + if [ -z "$changed" ]; then + echo "::error::No changelog entry found. Add a file under changelog/ (see changelog/README.md), or add the 'No changelog' label if this PR is docs/CI/deps-only." + exit 1 + fi + echo "Changelog entry present:" + echo "$changed" diff --git a/changelog/.gitkeep b/changelog/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/changelog/README.md b/changelog/README.md new file mode 100644 index 00000000..7332d3f6 --- /dev/null +++ b/changelog/README.md @@ -0,0 +1,22 @@ +# Changelog entries + +Every PR targeting `master` must add at least one file under this directory, +describing the user-facing change. A GitHub Actions workflow +(`.github/workflows/changelog.yml`) enforces this on every pull request. + +## Convention + +- One file per change. Name it after the Phabricator ticket (`T50530`) or, if + there is no ticket, a short descriptive slug (`access-log`). +- File content is one or more bullet lines describing the change, e.g.: + ``` + - [T50530] Bump sentry version + ``` +- Entries are collated into the top-level `CHANGELOG.md` at release time. + +## Skipping the check + +For docs-only, dependency-bump, or CI-only PRs that need no changelog entry, +add the `no-changelog` label to the PR. The workflow will skip the check. + +See `.github/workflows/changelog.yml` for the exact enforcement logic.