Skip to content

Commit 07a6f54

Browse files
authored
fix: update changelog workflow (#8)
- Add force push for existing branches - Improve error handling - Add write permissions for pull requests - Fix branch name handling
1 parent 4861ff0 commit 07a6f54

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

.github/workflows/update-changelog.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,14 @@ jobs:
1212
runs-on: ubuntu-latest
1313
permissions:
1414
contents: write
15-
pull-requests: read
15+
pull-requests: write
1616

1717
steps:
1818
- uses: actions/checkout@v4
1919
with:
2020
fetch-depth: 0
2121
ref: main
22+
token: ${{ secrets.GITHUB_TOKEN }}
2223

2324
- name: Get PR title and body
2425
id: pr-info
@@ -84,16 +85,19 @@ jobs:
8485
git config --local user.name "github-actions[bot]"
8586
8687
# Create branch, commit and push
87-
git checkout -b bot/update-changelog-v${NEW_VERSION}
88+
BRANCH_NAME="bot/update-changelog-v${NEW_VERSION}"
89+
git checkout -b "$BRANCH_NAME"
8890
git add CHANGELOG.md
8991
git commit -m "docs: update changelog for v${NEW_VERSION}"
90-
git push origin bot/update-changelog-v${NEW_VERSION}
9192
92-
# Create PR
93+
# Force push in case branch exists
94+
git push -f origin "$BRANCH_NAME"
95+
96+
# Create PR using GitHub CLI
9397
gh pr create \
9498
--title "docs: update changelog for v${NEW_VERSION}" \
9599
--body "Automated changelog update for version ${NEW_VERSION}" \
96100
--base main \
97-
--head bot/update-changelog-v${NEW_VERSION}
101+
--head "$BRANCH_NAME" || true
98102
env:
99103
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)