From 84100fc99eaf28dd7cfd273b5abf5ff8e164b0c7 Mon Sep 17 00:00:00 2001 From: Graeme Porteous Date: Thu, 26 Oct 2023 12:43:58 +0100 Subject: [PATCH] Add Github workflow to check for changelog entry When creating PR we should update the changelog as this helps others see what is upcoming in the next release and makes release Alaveteli versions easier. This workflow ensures an `docs/CHANGES.md` is modified or the pull request description contains `[skip changelog]` Update the PR template to help remind devs to do this before the PR is created. --- .github/PULL_REQUEST_TEMPLATE.md | 4 +++ .github/workflows/changelog.yml | 52 ++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 .github/workflows/changelog.yml diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index f9a6a6784fd..f96a3b8a008 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -9,3 +9,7 @@ ## Screenshots ## Notes to reviewer + +
+ +Have you updated the changelog? If this is not necessary, put square brackets around this: skip changelog diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml new file mode 100644 index 00000000000..b09f3269e49 --- /dev/null +++ b/.github/workflows/changelog.yml @@ -0,0 +1,52 @@ +name: Changelog + +on: + pull_request: + types: + - opened + - synchronize + - reopened + - edited + +jobs: + check: + runs-on: ubuntu-latest + continue-on-error: true + + env: + GH_TOKEN: ${{ github.token }} + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Check for [skip changelog] + id: skip + run: | + PR_DESCRIPTION=$(gh pr view https://github.com/${{ github.repository }}/pull/${{ github.event.pull_request.number }} --json body -q '.body') + if echo "$PR_DESCRIPTION" | grep -q "\[skip changelog\]"; then + echo "::set-output name=skip_changelog::true" + else + echo "::set-output name=skip_changelog::false" + fi + + - name: Check for changes in doc/CHANGES.md + id: changes + run: | + git fetch origin ${{ github.event.pull_request.base.ref }} + FILES_CHANGED=$(git diff --name-only origin/${{ github.event.pull_request.base.ref }} ${{ github.sha }}) + if [[ "$FILES_CHANGED" == *"doc/CHANGES.md"* ]]; then + echo "::set-output name=changes_found::true" + else + echo "::set-output name=changes_found::false" + fi + + - name: Final Check + run: | + if [[ "${{ steps.skip.outputs.skip_changelog }}" == "true" || "${{ steps.changes.outputs.changes_found }}" == "true" ]]; then + echo "Either [skip changelog] was found or doc/CHANGES.md was modified. Passing the action." + exit 0 + else + echo "Neither [skip changelog] was found nor was doc/CHANGES.md modified. Failing the action." + exit 1 + fi