GitHub has the deprecated merge_commit_sha attribute because it is confusing. As they describe here :
The merge_commit_sha attribute holds the SHA of the test merge commit
This means that GitHub creates a special branch in which they combine the main and request request branches, and merge_commit_sha indicates that the surrogate merge, but you do not have it in your local repo. You will need to get the special pr/<pull_request_id>/merge branch to see this commit.
Good thing you can do this before merging the pull request. And tools like the Jenkins GitHub pull query builder use this technique. Meanwhile, commit_sha is the actual merge, so you can return it.
So, if still unclear, merge_commit_sha really gives you the correct commit command, but to use it you must first extract the pr/<pull_request_id>/merge branch. To avoid future obsolescence issues, you can get the head commit of the above merge branch instead of using merge_commit_sha .
By the way, if you are building something with Hubot, you can check out this book (shameless plugin). It includes a chapter on GitHub integration.
source share