@@ -39,23 +39,32 @@ jobs:
39
39
run : |
40
40
rm git-chglog
41
41
42
- - name : Create and Switch to New Branch
42
+ - name : Check for Changes
43
+ id : check_changes
43
44
run : |
44
- git checkout -b update-changelog-${{ github.run_id }}
45
+ if git diff --quiet CHANGELOG.md; then
46
+ echo "No changes in CHANGELOG.md"
47
+ echo "::set-output name=changes::false"
48
+ else
49
+ echo "Changes detected in CHANGELOG.md"
50
+ echo "::set-output name=changes::true"
51
+ fi
45
52
46
- - name : Commit Changelog
53
+ - name : Commit and Push Changes
54
+ if : steps.check_changes.outputs.changes == 'true' # Only run if there are changes
47
55
uses : stefanzweifel/git-auto-commit-action@v5
48
56
with :
49
57
commit_message : " Update CHANGELOG"
50
58
file_pattern : CHANGELOG.md
51
- branch : update-changelog-${{ github.run_id }} # Commit to the new branch
59
+ branch : update-changelog-${{ github.run_id }}
52
60
53
61
- name : Create Pull Request
62
+ if : steps.check_changes.outputs.changes == 'true' # Only run if there are changes
54
63
uses : peter-evans/create-pull-request@v4
55
64
with :
56
65
commit-message : " Update CHANGELOG"
57
66
title : " Update Changelog"
58
67
body : " This PR updates the entire CHANGELOG to include all releases."
59
- branch : update-changelog-${{ github.run_id }} # Match the branch from the previous step
60
- base : main # Target branch for PR
68
+ branch : update-changelog-${{ github.run_id }}
69
+ base : main
61
70
delete-branch : true # Automatically delete branch after merge
0 commit comments