Skip to content

Commit

Permalink
Add Github workflow to check for changelog entry
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
gbp committed Oct 26, 2023
1 parent 53fa606 commit 035649e
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@
## Screenshots

## Notes to reviewer

<hr>

Have you updated the changelog? If this is not necessary, put square brackets around this: skip changelog
52 changes: 52 additions & 0 deletions .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
@@ -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 "skip_changelog=true" >> $GITHUB_OUTPUT
else
echo "skip_changelog=false" >> $GITHUB_OUTPUT
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 "changes_found=true" >> $GITHUB_OUTPUT
else
echo "changes_found=false" >> $GITHUB_OUTPUT
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

0 comments on commit 035649e

Please sign in to comment.