@@ -33,59 +33,58 @@ jobs:
3333 env :
3434 GITHUB_REPO : ${{ github.repository }}
3535
36- - name : Fetch latest main
37- run : git fetch origin main
38-
39- - name : Create worktree for changelog
40- run : git worktree add worktree-changelog origin/main
41-
42- - name : Generate full changelog in worktree
36+ - name : Generate full changelog
4337 uses : orhun/git-cliff-action@v4
4438 with :
4539 config : pyproject.toml
4640 args : -vv
4741 env :
48- OUTPUT : worktree-changelog/ docs/changelog.rst
42+ OUTPUT : docs/changelog.rst
4943 GITHUB_REPO : ${{ github.repository }}
5044
5145 - name : Create PR with changelog updates
52- working-directory : worktree-changelog
5346 run : |
5447 git config user.name 'github-actions[bot]'
5548 git config user.email 'github-actions[bot]@users.noreply.github.com'
56- git add docs/changelog.rst
57- if git diff --staged --quiet; then
49+
50+ # Check if there are changes
51+ if git diff --quiet docs/changelog.rst; then
5852 echo "No changes to commit"
59- else
60- # Create unique branch name (includes run ID to avoid collisions on reruns)
61- BRANCH_NAME="changelog/update-$(git rev-parse --short HEAD)-${{ github.run_id }}"
62- git checkout -b "$BRANCH_NAME"
53+ exit 0
54+ fi
6355
64- git commit -m "docs: update changelog"
56+ # Create unique branch name
57+ BRANCH_NAME="changelog/update-$(git rev-parse --short HEAD)-${{ github.run_id }}"
6558
66- # Push and create PR
67- git push origin "$BRANCH_NAME"
68- gh pr create \
69- --base main \
70- --head "$BRANCH_NAME" \
71- --title "docs: update changelog" \
72- --body "Automated changelog update generated by git-cliff. This PR updates the changelog with the latest commits." \
73- --label "documentation" \
74- --label "automated"
75- fi
59+ # Fetch and checkout main, then create new branch
60+ git fetch origin main
61+ git checkout -b "$BRANCH_NAME" origin/main
62+
63+ # Re-generate changelog on the new branch
64+ git-cliff -vv -o docs/changelog.rst
65+
66+ # Commit and push
67+ git add docs/changelog.rst
68+ git commit -m "docs: update changelog"
69+ git push origin "$BRANCH_NAME"
70+
71+ # Create PR
72+ gh pr create \
73+ --base main \
74+ --head "$BRANCH_NAME" \
75+ --title "docs: update changelog" \
76+ --body "Automated changelog update generated by git-cliff. This PR updates the changelog with the latest commits." \
77+ --label "documentation" \
78+ --label "automated"
7679 env :
7780 GH_TOKEN : ${{ github.token }}
81+ GITHUB_REPO : ${{ github.repository }}
7882
7983 - name : Update GitHub release body
8084 if : github.event_name == 'release'
8185 run : |
82- # Update release body with latest changelog
8386 gh release edit "${{ github.event.release.tag_name }}" \
8487 --notes "${{ steps.git-cliff-latest.outputs.content }}" \
8588 --repo ${{ github.repository }}
8689 env :
8790 GH_TOKEN : ${{ github.token }}
88-
89- - name : Cleanup worktree
90- if : always()
91- run : git worktree remove worktree-changelog || true
0 commit comments