Skip to content

Commit d2c24f6

Browse files
committed
Fix
1 parent c734165 commit d2c24f6

File tree

1 file changed

+32
-36
lines changed

1 file changed

+32
-36
lines changed

.github/workflows/update-changelog.yml

+32-36
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ name: "Update Changelog"
33
on:
44
release:
55
types: [published] # Trigger on release publication
6-
workflow_dispatch: # Allows manual trigger of this workflow
6+
workflow_dispatch: # Allows manual trigger
77

88
permissions:
9-
contents: write
9+
contents: write # Minimum required permission for file changes and PR creation
10+
pull-requests: write # Required for creating PRs
1011

1112
jobs:
1213
update-changelog:
@@ -17,54 +18,49 @@ jobs:
1718
- name: Checkout code
1819
uses: actions/checkout@v4
1920
with:
20-
fetch-depth: 0 # Fetch full history to access all tags
21-
ref: main # Ensure we're starting from main branch
21+
fetch-depth: 0 # Fetch full history for changelog generation
22+
ref: main # Start from main branch
2223

23-
- name: Install git-chglog
24+
- name: Setup git-chglog
2425
run: |
25-
curl -o git-chglog -L https://github.com/git-chglog/git-chglog/releases/download/0.9.1/git-chglog_linux_amd64
26+
CHGLOG_VERSION="0.9.1"
27+
curl -o git-chglog -L "https://github.com/git-chglog/git-chglog/releases/download/${CHGLOG_VERSION}/git-chglog_linux_amd64"
2628
chmod +x git-chglog
2729
28-
- name: Remove Existing CHANGELOG.md
29-
run: |
30-
rm -f CHANGELOG.md # Remove the existing changelog to allow complete regeneration
31-
32-
- name: Generate New CHANGELOG.md
30+
- name: Generate CHANGELOG.md
31+
id: generate
3332
run: |
33+
rm -f CHANGELOG.md # Remove existing changelog
3434
./git-chglog -o CHANGELOG.md
35-
env:
36-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37-
38-
- name: Clean up git-chglog
39-
run: |
40-
rm git-chglog
4135
42-
- name: Check for Changes
43-
id: check_changes
44-
run: |
36+
# Check for changes and set output
4537
if git diff --quiet CHANGELOG.md; then
46-
echo "No changes in CHANGELOG.md"
47-
echo "::set-output name=changes::false"
38+
echo "changes=false" >> $GITHUB_OUTPUT
4839
else
49-
echo "Changes detected in CHANGELOG.md"
50-
echo "::set-output name=changes::true"
40+
echo "changes=true" >> $GITHUB_OUTPUT
5141
fi
42+
env:
43+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5244

53-
- name: Commit and Push Changes
54-
if: steps.check_changes.outputs.changes == 'true' # Only run if there are changes
55-
uses: stefanzweifel/git-auto-commit-action@v5
56-
with:
57-
commit_message: "Update CHANGELOG"
58-
file_pattern: CHANGELOG.md
59-
branch: update-changelog-${{ github.run_id }}
45+
- name: Cleanup
46+
run: rm git-chglog
47+
if: always() # Ensure cleanup happens even if previous steps fail
6048

6149
- name: Create Pull Request
62-
if: steps.check_changes.outputs.changes == 'true' # Only run if there are changes
50+
if: steps.generate.outputs.changes == 'true'
6351
uses: peter-evans/create-pull-request@v4
6452
with:
65-
commit-message: "Update CHANGELOG"
66-
title: "Update Changelog"
67-
body: "This PR updates the entire CHANGELOG to include all releases."
53+
token: ${{ secrets.GITHUB_TOKEN }}
54+
commit-message: "chore: update CHANGELOG.md"
55+
title: "📝 Update Changelog"
56+
body: |
57+
This PR updates the CHANGELOG.md to include all releases.
58+
59+
- Generated using git-chglog
60+
- Triggered by: ${{ github.event_name }}
6861
branch: update-changelog-${{ github.run_id }}
6962
base: main
70-
delete-branch: true # Automatically delete branch after merge
63+
delete-branch: true
64+
labels: |
65+
documentation
66+
automated-pr

0 commit comments

Comments
 (0)