Skip to content

Commit 4a732f6

Browse files
committed
chore(ci): create PR for changelog updates instead of pushing to main
1 parent 0d6214b commit 4a732f6

1 file changed

Lines changed: 24 additions & 3 deletions

File tree

.github/workflows/publish.yaml

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ jobs:
7979
needs: [publish-package]
8080
permissions:
8181
contents: write
82+
pull-requests: write
8283
steps:
8384
- name: Checkout
8485
uses: actions/checkout@v4
@@ -95,13 +96,33 @@ jobs:
9596
- name: Generate release notes
9697
run: git cliff --latest --strip header -o RELEASE_NOTES.md
9798

98-
- name: Commit changelog
99+
- name: Commit changelog to branch
99100
run: |
100101
git config user.name "github-actions[bot]"
101102
git config user.email "github-actions[bot]@users.noreply.github.com"
103+
104+
BRANCH="changelog/${{ github.ref_name }}-${{ github.run_id }}"
105+
git checkout -b "$BRANCH"
106+
102107
git add CHANGELOG.md
103-
git diff --staged --quiet || git commit -m "chore: update changelog for ${{ github.ref_name }}"
104-
git push origin HEAD:main
108+
if git diff --staged --quiet; then
109+
echo "No changelog changes; skipping commit + PR."
110+
exit 0
111+
fi
112+
113+
git commit -m "chore: update changelog for ${{ github.ref_name }}"
114+
git push origin "$BRANCH"
115+
116+
- name: Create pull request for changelog
117+
uses: peter-evans/create-pull-request@v6
118+
with:
119+
token: ${{ secrets.GITHUB_TOKEN }}
120+
base: main
121+
branch: changelog/${{ github.ref_name }}-${{ github.run_id }}
122+
title: "chore: update changelog for ${{ github.ref_name }}"
123+
body: |
124+
Automated changelog update for `${{ github.ref_name }}`.
125+
commit-message: "chore: update changelog for ${{ github.ref_name }}"
105126

106127
- name: Upload release notes
107128
uses: actions/upload-artifact@v4

0 commit comments

Comments
 (0)