From ed4a57f696eb9640c07d38670f7c0a67c478a522 Mon Sep 17 00:00:00 2001 From: kaysiz Date: Thu, 12 Mar 2026 10:22:18 +0100 Subject: [PATCH 1/2] update changelog workflow --- .github/workflows/changelog.yml | 38 ++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml index d6e0810..107d072 100644 --- a/.github/workflows/changelog.yml +++ b/.github/workflows/changelog.yml @@ -15,22 +15,40 @@ jobs: runs-on: ubuntu-latest name: Generate changelog steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Generate changelog - uses: charmixer/auto-changelog-action@v1.1 + uses: charmixer/auto-changelog-action@v1 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 }} From 628d9f5e145d51bda0efcb28580e6f95796c93f5 Mon Sep 17 00:00:00 2001 From: kaysiz Date: Thu, 12 Mar 2026 10:27:22 +0100 Subject: [PATCH 2/2] add guards against infinite PR creation --- .github/workflows/changelog.yml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml index 107d072..7b081d2 100644 --- a/.github/workflows/changelog.yml +++ b/.github/workflows/changelog.yml @@ -14,11 +14,20 @@ 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@v4 + - uses: actions/checkout@v3 - name: Generate changelog - uses: charmixer/auto-changelog-action@v1 + uses: charmixer/auto-changelog-action@v1.1 with: token: ${{ secrets.GITHUB_TOKEN }}