-->

How to create a tag on GitHub when a PR is merged?

2020-06-20 13:08发布

问题:

My current workflow requires a version Bump on every PR, so I would like to take advantage of that and automatically create a tag on GitHub on every PR merge, so it appears in the "release" section.

I've seen that I can write a post-merge hook. My doubt is if that hook runs locally in my machine, remotely on GitHub, or both (given that I merge the PR on GitHub, and not locally. What's the case?

回答1:

I can write a post-merge hook. My doubt is if that hook runs locally in my machine, remotely on GitHub, or both

It will certainly not run on GitHub (that wouldn't be safe for GitHub to run any user-provided hook).

What you can have is a Webhook on pull request: by listening to its JSON payload, you can add a tag and push it back to GitHub if the PR event indicated a merged PR.
(That is, if the action is "closed", and the merged key is "true")