From 0008da3b019ae091baca73de1be77ffe069e5953 Mon Sep 17 00:00:00 2001 From: messense Date: Mon, 19 Sep 2022 23:45:39 +0800 Subject: [PATCH] Enforce changelog entry for PR --- .github/workflows/changelog.yml | 35 +++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/changelog.yml diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml new file mode 100644 index 00000000..ae3eaf3f --- /dev/null +++ b/.github/workflows/changelog.yml @@ -0,0 +1,35 @@ +name: changelog + +on: + pull_request: + types: [opened, synchronize, labeled, unlabeled] + +jobs: + check: + name: Check changelog entry + runs-on: ubuntu-latest + if: ${{ !contains(github.event.pull_request.labels.*.name, 'CI-skip-changelog') }} + steps: + - uses: actions/checkout@v3 + - uses: actions/github-script@v6 + id: check + with: + script: | + const fs = require('node:fs') + const path = require('node:path') + + let found = false + const changeTypes = ['packaging', 'added', 'changed', 'removed', 'fixed'] + for (changeType of changeTypes) { + const filename = path.join('newsfragments', `${context.issue.number}.${changeType}.md`) + if (fs.existsSync(filename)) { + found = true + break + } + } + + if (!found) { + const errorMsg = '📝 Changelog entry not found, please add one (or more) to `newsfragments` directory. For more information see https://github.com/PyO3/pyo3/blob/main/Contributing.md#documenting-changes' + core.error(errorMsg) + process.exit(1) + }