summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcyqsimon <28627918+cyqsimon@users.noreply.github.com>2023-11-03 15:53:29 +0800
committerGitHub <noreply@github.com>2023-11-03 08:53:29 +0100
commitbcc2de86b47c26ad5393588aaead540e348dfc3c (patch)
treea291468f3b1ebf557b2e9ba0f8832eef4d061c18
parent1296aea836d3368c08a3b6e1f949c4a86f15bc75 (diff)
CI: add changelog check (#2766)
* Added changelog item check Fetch the base branch and diff correctly - See: https://github.com/actions/checkout/issues/160 Improve organisation Add some echo for easier debugging Fix bad variable syntax Clarify the double-print in the success case * Write to changelog * Don't block dependabot PRs
-rw-r--r--.github/workflows/require-changelog-for-PRs.yml26
-rw-r--r--CHANGELOG.md1
2 files changed, 27 insertions, 0 deletions
diff --git a/.github/workflows/require-changelog-for-PRs.yml b/.github/workflows/require-changelog-for-PRs.yml
new file mode 100644
index 00000000..518fa9d5
--- /dev/null
+++ b/.github/workflows/require-changelog-for-PRs.yml
@@ -0,0 +1,26 @@
+name: Changelog
+
+on:
+ pull_request:
+
+jobs:
+ check-changelog:
+ name: Check for changelog entry
+ runs-on: ubuntu-latest
+ # dependabot PRs are automerged if CI passes; we shouldn't block these
+ if: github.actor != 'dependabot[bot]'
+ env:
+ PR_SUBMITTER: ${{ github.actor }}
+ PR_NUMBER: ${{ github.event.number }}
+ PR_BASE: ${{ github.base_ref }}
+ steps:
+ - uses: actions/checkout@v4
+ - name: Fetch PR base
+ run: git fetch --no-tags --prune --depth=1 origin
+ - name: Search for added line in changelog
+ run: |
+ ADDED=$(git diff -U0 "origin/${PR_BASE}" HEAD -- CHANGELOG.md | grep -P '^\+[^\+].+$')
+ echo "Added lines in CHANGELOG.md:"
+ echo "$ADDED"
+ echo "Grepping for PR info:"
+ grep "#${PR_NUMBER}\\b.*@${PR_SUBMITTER}\\b" <<< "$ADDED"
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d63e98a9..d12cb8fe 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,7 @@
- Upgrade to Rust 2021 edition #2748 (@cyqsimon)
- Refactor and cleanup build script #2756 (@cyqsimon)
+- Checks changelog has been written to for PRs in CI #2766 (@cyqsimon)
## Syntaxes