From 367ad2f6c9a1f73449bd3f77be248da409cf4096 Mon Sep 17 00:00:00 2001 From: cyqsimon <28627918+cyqsimon@users.noreply.github.com> Date: Fri, 3 Nov 2023 11:07:19 +0800 Subject: [PATCH] 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 --- .../workflows/require-changelog-for-PRs.yml | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/workflows/require-changelog-for-PRs.yml diff --git a/.github/workflows/require-changelog-for-PRs.yml b/.github/workflows/require-changelog-for-PRs.yml new file mode 100644 index 0000000000..0c1c3b6439 --- /dev/null +++ b/.github/workflows/require-changelog-for-PRs.yml @@ -0,0 +1,24 @@ +name: Changelog + +on: + pull_request: + +jobs: + check-changelog: + name: Check for changelog entry + runs-on: ubuntu-latest + 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"