-
Notifications
You must be signed in to change notification settings - Fork 11
feat: GHA workflow to enforce changelog updates #197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
rjan90
wants to merge
4
commits into
main
Choose a base branch
from
phi/changelog-check
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
c8f22d4
feat: GHA workflow to enforce changelog updates
rjan90 e18b1e0
Update .github/workflows/changelog.yml
rjan90 7e9b63c
fix: update regex pattern to avoid false positives
rjan90 256822b
Merge branch 'phi/changelog-check' of https://github.com/FilOzone/pdp…
rjan90 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
name: Changelog Check | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
- master | ||
types: [opened, synchronize, reopened, edited, labeled, unlabeled] | ||
|
||
jobs: | ||
check-changelog: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Check if changelog should be skipped | ||
id: skip_check | ||
run: | | ||
# Check for skip/changelog label | ||
if [[ "${{ contains(github.event.pull_request.labels.*.name, 'skip/changelog') }}" == "true" ]]; then | ||
echo "skip=true" >> $GITHUB_OUTPUT | ||
echo "Changelog check skipped due to 'skip/changelog' label" | ||
exit 0 | ||
fi | ||
|
||
# Check for skip indicators in PR title | ||
PR_TITLE="${{ github.event.pull_request.title }}" | ||
if echo "$PR_TITLE" | grep -iqE '\[(skip|no)\s?changelog\]'; then | ||
echo "skip=true" >> $GITHUB_OUTPUT | ||
echo "Changelog check skipped due to skip indicator in PR title: $PR_TITLE" | ||
exit 0 | ||
fi | ||
|
||
# Check for skip indicators in PR description | ||
PR_BODY="${{ github.event.pull_request.body }}" | ||
if echo "$PR_BODY" | grep -iqE '\[(skip|no)\s?changelog\]'; then | ||
echo "skip=true" >> $GITHUB_OUTPUT | ||
echo "Changelog check skipped due to skip indicator in PR description" | ||
exit 0 | ||
fi | ||
|
||
echo "skip=false" >> $GITHUB_OUTPUT | ||
echo "Changelog check required" | ||
|
||
- name: Check for CHANGELOG.md changes | ||
if: steps.skip_check.outputs.skip != 'true' | ||
id: changelog_check | ||
run: | | ||
# Ensure the base branch exists locally | ||
git fetch origin ${{ github.base_ref }} | ||
# Get the list of changed files in this PR | ||
CHANGED_FILES=$(git diff --name-only origin/${{ github.base_ref }}...HEAD) | ||
|
||
echo "Changed files in this PR:" | ||
echo "$CHANGED_FILES" | ||
|
||
# Check if CHANGELOG.md is in the list of changed files | ||
if echo "$CHANGED_FILES" | grep -q "^CHANGELOG.md$"; then | ||
echo "✅ CHANGELOG.md has been updated" | ||
echo "changelog_updated=true" >> $GITHUB_OUTPUT | ||
else | ||
echo "❌ CHANGELOG.md has not been updated" | ||
echo "changelog_updated=false" >> $GITHUB_OUTPUT | ||
fi | ||
|
||
- name: Fail if changelog not updated | ||
if: steps.skip_check.outputs.skip != 'true' && steps.changelog_check.outputs.changelog_updated != 'true' | ||
run: | | ||
echo "::error title=Changelog Required::CHANGELOG.md must be updated for this pull request. Please add an entry describing your changes under the [Unreleased] section." | ||
echo "" | ||
echo "If this PR doesn't require a changelog entry (e.g., documentation-only changes, CI changes), you can skip this check by:" | ||
echo "• Adding the 'skip/changelog' label to this PR, OR" | ||
echo "• Including '[skip changelog]' or '[no changelog]' in the PR title or description" | ||
echo "" | ||
echo "Examples:" | ||
echo " Title: 'Fix typo in README [skip changelog]'" | ||
echo " Description: 'This is a minor documentation fix [no changelog]'" | ||
echo "" | ||
echo "For more information about our changelog format, see: https://keepachangelog.com/en/1.0.0/" | ||
exit 1 | ||
|
||
- name: Success message | ||
if: steps.skip_check.outputs.skip == 'true' || steps.changelog_check.outputs.changelog_updated == 'true' | ||
run: | | ||
if [[ "${{ steps.skip_check.outputs.skip }}" == "true" ]]; then | ||
echo "✅ Changelog check skipped (via label or PR title/description)" | ||
else | ||
echo "✅ Changelog check passed - CHANGELOG.md has been updated" | ||
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.