我目前的工作流程需要在每个 PR 上都有一个版本 Bump,所以我想利用它并在每个 PR merge 时自动在 GitHub 上创建一个标签,所以它出现在“发布”部分。
我发现我可以编写 merge 后 Hook 。我怀疑该 Hook 是在我的机器上本地运行,还是在 GitHub 上远程运行,或者两者兼而有之(假设我在 GitHub 上 merge 了 PR,而不是在本地。这是怎么回事?
最佳答案
I can write a post-merge hook. My doubt is if that hook runs locally in my machine, remotely on GitHub, or both
2015:它肯定不会在 GitHub 上运行(GitHub 运行任何用户提供的 Hook 都不安全)。
你可以拥有一个 Webhook on pull request :通过监听其 JSON 负载,如果 PR event 可以添加标签并将其推回 GitHub 表示 merge PR。
(也就是说,如果 action
是“closed
”,并且 merged
键是“true
”)
2020:一定会跑在GitHub上:那叫GitHub Actions .
在 OP 的例子中,GitHub Tag Action .
A GitHub Action to automatically bump and tag master, on merge, with the latest SemVer formatted version. Works on any platform.
Usage
name: Bump version
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
with:
# Fetches entire history, so we can analyze commits since last tag
fetch-depth: 0
- name: Bump version and push tag
uses: mathieudutour/github-tag-action@v4.5
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
类似且更新的操作:github-tag-action .
请参阅 Creating A Github Action to Tag Commits 中的“Nick Sjostrom” .
name: Bump version
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Bump version and push tag
uses: anothrNick/github-tag-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO_OWNER: anothrNick
关于git - merge PR 时如何在 GitHub 上创建标签?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31602068/