Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 35 additions & 8 deletions .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ jobs:
generate_changelog:
runs-on: ubuntu-latest
name: Generate changelog
# Skip if the PR was created by the GitHub Action or is a changelog update (to prevent infinite loops)
if: >
github.event_name != 'pull_request' ||
(
github.event.pull_request.merged == true &&
github.event.pull_request.user.login != 'github-actions[bot]' &&
!contains(github.event.pull_request.head.ref, 'changelog-update') &&
!contains(github.event.pull_request.title, 'Auto-update CHANGELOG.md')
)
steps:
- uses: actions/checkout@v3

Expand All @@ -22,15 +31,33 @@ jobs:
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Commit files
- name: Create Pull Request
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add CHANGELOG.md && git commit -m 'Updated CHANGELOG.md'

- name: Push changes
uses: ad-m/github-push-action@v0.6.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: 'refs/heads/master'
tags: false
# Check if there are changes to commit
if ! git diff --quiet CHANGELOG.md; then
echo "Changes detected in CHANGELOG.md, creating pull request..."

# Create a new branch for the changelog update
BRANCH_NAME="changelog-update-$(date +%s)"
git checkout -b "$BRANCH_NAME"

# Add and commit the changelog
git add CHANGELOG.md && git commit -m 'Updated CHANGELOG.md'

# Push the branch
git push origin "$BRANCH_NAME"

# Create a pull request using GitHub CLI
gh pr create \
--title "Auto-update CHANGELOG.md" \
--body "Automated changelog update triggered by recent activity. This PR was automatically generated by the changelog workflow." \
--base master \
--head "$BRANCH_NAME"
else
echo "No changes detected in CHANGELOG.md, skipping pull request creation."
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Loading