diff --git a/.github/workflows/auto-changelog.yml b/.github/workflows/auto-changelog.yml index 0f58ff05..425d07a0 100644 --- a/.github/workflows/auto-changelog.yml +++ b/.github/workflows/auto-changelog.yml @@ -58,20 +58,21 @@ jobs: echo 'Preview:' grep -n "^${{ steps.detect.outputs.version }}$" -A12 docs/change_log.md || true - - name: Commit changes + - name: Stage changes if: ${{ steps.detect.outputs.update == 'true' }} run: | set -e - git config user.name 'github-actions[bot]' - git config user.email 'github-actions[bot]@users.noreply.github.com' - branch="chore/changelog-${{ steps.detect.outputs.version }}" + # Ensure we are on the correct base branch before staging base="${{ steps.detect.outputs.base }}" + git checkout -B "$base" "origin/$base" - # Create new branch from remote base - git checkout -b "$branch" "origin/$base" + # Run generation again to ensure file is updated in the correct branch context if needed + # (Optional, but safe if the previous step modified a file in a detached head or different branch) + python .github/scripts/gen_changelog.py "${{ steps.detect.outputs.version }}" + git config user.name 'github-actions[bot]' + git config user.email 'github-actions[bot]@users.noreply.github.com' git add docs/change_log.md - git commit -m "chore: add changelog for ${{ steps.detect.outputs.version }}" - name: Create Pull Request if: ${{ steps.detect.outputs.update == 'true' }}