pascalgn / automerge-action

GitHub action to automatically merge pull requests that are ready
MIT License
847 stars 207 forks source link

Append PR number to merge commit message #255

Open hwhsu1231 opened 7 months ago

hwhsu1231 commented 7 months ago

Feature Request

When merging a pull request on the GitHub web client, the suggested commit message (at least in the case of a squash commit, which we always use) will automatically include the number of the PR in parentheses, like so:

Update project files (#123)

However, when merging using this GitHub Action, the first line of the commit message will look like this:

Update project files

No matter what option of MERGE_COMMIT_MESSAGE I choose:

Therefore, I hope that it can append (#NUM) to the first line of the commit message for all possible options.

Versions

Current latest release: v0.16.2

hwhsu1231 commented 7 months ago

Related to this part?

https://github.com/pascalgn/automerge-action/blob/58724c982461efbb7865b3762d7bff0d4756f57a/lib/merge.js#L376-L392

hwhsu1231 commented 7 months ago

Hello, @pascalgn

I think the current alternative to appending PR number is to customize the commit message ourselves. For example, if I want to append a PR number to "pull-request-title" option of MERGE_COMMIT_MESSAGE, I can write it like this:

{pullRequest.title} (#{pullRequest.number})

The full example may look like this:

- name: Automerge a PR with 'automerge' label
  id: automerge
  uses: "pascalgn/automerge-action@v0.16.2"
  env:
    GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
    MERGE_METHOD: 'squash'
    MERGE_COMMIT_MESSAGE: '{pullRequest.title} (#{pullRequest.number})'
    UPDATE_METHOD: 'rebase'

But I hope that this GitHub Action can append (#PR) to the title of message by default. Can you fix this issue by appending (#PR) for all the options of MERGE_COMMIT_MESSAGE?