Skip to content

Commit 4a1b036

Browse files
committed
refactor: simplify changelog update check logic in GitHub Actions workflow
1 parent 63ca1e9 commit 4a1b036

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed

.github/workflows/changelog.yml

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,18 @@ jobs:
2626
- name: Check for changes since last changelog update
2727
id: check_changes
2828
run: |
29-
# Get the last commit that modified CHANGELOG.md
30-
LAST_CHANGELOG_COMMIT=$(git log -1 --format="%H" -- CHANGELOG.md 2>/dev/null || echo "")
31-
32-
if [ -z "$LAST_CHANGELOG_COMMIT" ]; then
33-
echo "No previous changelog found, generating full changelog"
34-
echo "has_changes=true" >> $GITHUB_OUTPUT
35-
else
36-
# Check if there are commits since the last changelog update
37-
COMMITS_SINCE=$(git rev-list --count ${LAST_CHANGELOG_COMMIT}..HEAD)
38-
if [ "$COMMITS_SINCE" -gt 1 ]; then
39-
echo "Found $COMMITS_SINCE commits since last changelog update"
40-
echo "has_changes=true" >> $GITHUB_OUTPUT
41-
else
42-
echo "No new commits to add to changelog"
43-
echo "has_changes=false" >> $GITHUB_OUTPUT
44-
fi
29+
# Check if this commit is a changelog update commit
30+
CURRENT_COMMIT_MSG=$(git log -1 --format="%s")
31+
if [[ "$CURRENT_COMMIT_MSG" == *"docs: update changelog"* ]]; then
32+
echo "Current commit is a changelog update, skipping"
33+
echo "has_changes=false" >> $GITHUB_OUTPUT
34+
exit 0
4535
fi
36+
37+
# Always generate changelog for non-changelog commits
38+
# This ensures we capture all changes and git-cliff will handle duplicates
39+
echo "Non-changelog commit detected, generating changelog"
40+
echo "has_changes=true" >> $GITHUB_OUTPUT
4641
4742
- name: Generate changelog
4843
if: steps.check_changes.outputs.has_changes == 'true'

0 commit comments

Comments
 (0)