diff --git a/.github/workflows/release-new.yml b/.github/workflows/release-new.yml index 7b84600..d6b34ab 100644 --- a/.github/workflows/release-new.yml +++ b/.github/workflows/release-new.yml @@ -83,9 +83,21 @@ jobs: - name: Write changelog to file run: echo "${{ steps.changelog.outputs.changelog }}" > CHANGELOG.md + - name: Get the branch name + id: branch_name + run: | + if [ "${{ github.event_name }}" = "pull_request" ]; then + echo "::set-output name=branch::${{ github.head_ref }}" + elif [[ "${GITHUB_REF}" == refs/tags/* ]]; then + echo "::set-output name=branch::main" # replace 'main' with your default branch name + else + echo "::set-output name=branch::${GITHUB_REF#refs/heads/}" + fi + - name: Commit CHANGELOG.md uses: stefanzweifel/git-auto-commit-action@v5 with: + branch: ${{ steps.branch_name.outputs.branch }} commit_message: 'docs: update CHANGELOG.md for ${{ github.ref_name }} [skip ci]' file_pattern: CHANGELOG.md