Skip to content

Commit

Permalink
Add a workflow looking for changelog fragments
Browse files Browse the repository at this point in the history
Closes:: #186
  • Loading branch information
rrey committed May 1, 2022
1 parent a820865 commit 931921b
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/fragment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
on:
pull_request:

name: Check changelog fragment
jobs:
check_fragment:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Automatic Rebase
run: ./hacking/check_fragment.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.number }}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ See LICENCE to see the full text.

Any contribution is welcome and we only ask contributors to:
* Provide *at least* integration tests for any contribution.
* The Pull Request *MUST* contain a changelog fragment. See [Ansible documentation](https://docs.ansible.com/ansible/latest/community/development_process.html#creating-a-changelog-fragment) about fragments.
* Create an issue for any significant contribution that would change a large portion of the code base.

## Contributors ✨
Expand Down
7 changes: 7 additions & 0 deletions hacking/NEED_FRAGMENT
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Dear contributor,

Thank you for you Pull Request !
To ease the work of maintainers you need to add a [changelog fragment](https://docs.ansible.com/ansible/latest/community/development_process.html#creating-a-changelog-fragment) in you PR.

It will help your change be released faster !
Thank you !
29 changes: 29 additions & 0 deletions hacking/check_fragment.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

function comment() {
echo "No fragment detected"
if [ -n "$PR_NUMBER" ]; then
gh pr review $PR_NUMBER -r -F $(git rev-parse --show-toplevel)/hacking/NEED_FRAGMENT
fi
exit 1
}

function approve() {
if [ -n "$PR_NUMBER" ]; then
gh pr review $PR_NUMBER -a
fi
}

if [ -z "$GITHUB_BASE_REF" ]; then
GITHUB_BASE_REF="origin/main"
fi

echo "Comparing HEAD with $GITHUB_BASE_REF"

FRAGMENTS=$(git diff --name-only --diff-filter=ACMRT $GITHUB_BASE_REF..HEAD | grep "changelogs/fragments")

if [ -z "$FRAGMENTS" ]; then
comment
else
aprove
fi

0 comments on commit 931921b

Please sign in to comment.