How to trigger a event only after PR is merged(not new commits pushing to this PR)

One PR is that the original branch is feature_branch and the target branch is dev. During this period, there will be many new commits, and each time the PR is triggered to be re-run by travis, then finally merged to the dev branch.

What I want to do is to add a decision condition that triggers a script (e.g. sending mail/logging, etc.) only after featurestrong text_branch is merged into dstrong textev, and multiple commits during the period will not trigger this script.

Seeing a potentially useful TRAVIS environment variable is $TRAVIS_emphasized textBRANCH, but found that both the intermediate commit and the final merge result are dev, which cannot be used as a basis for judgment. Any ideas about it ? I have run multiple tests and totally lost now…

You can detect if the commit is a merge commit with Git’s means: