如何控制在 CircleCI 中为哪些 github 提交构建?
How to control which github commits to build for in CircleCI?
我想设置一个 CI 以便它仅在 git 提交被 GitHub webhooks 报告时做出反应和构建,包含我的子文件夹中任何内容的更改回购。
myRepo
> code1.js
> workers <-- run when this ... or anything under this changes
> worker1.js
例如,我想设置一个可以查看提交的 CircleCI 构建和 运行 一个脚本来根据提交变更日志决定 go? or no-go?
构建匹配在更改日志负载中搜索 workers
的正则表达式。
我只是不知道在哪里挂钩以及如何:
- 我是否应该设置我的 github webhook 以某种方式更智能并辨别更新日志是否有任何提及
workers
文件夹的内容?这样我的 CI 就可以保持沉默,因为 webhook 会自行决定何时将提交有效负载推送到 CI。
- 我是否应该以某种方式挂接到 CircleCI 的 yaml 文件中,以辨别变更日志是否有任何提及
workers
文件夹的内容?如果是,在哪里?
我可以编写自己的正则表达式,但我需要知道在哪里 inject/hook-in 脚本。
我不要求的东西:
- 我不要求 git 子模块
等替代方案
- 我不想分成两个单独的存储库
CircleCI 不支持内置此功能。在 CircleCI 方面,您肯定可以在 circle.yml
中有一些逻辑来检查 workers
目录中的更改,但是我们只会在构建过程开始后才对其进行评估。效率不高。
至于 GitHub webhooks,我不知道可以做这样的事情。如果是这样,那就太棒了,请告诉我。
我的建议
CircleCI 确实支持 [skip ci] or [ci skip]
flag in the commit message. If changes outside of the workers
directory is infrequent, simply add that flag to the commit message. If changes happen often, that'll be tedious so instead I'd use the Git commit-msg
hook. You can write a small script for that hook to check which directories contained changes. If anything inside workers/*
wasn't changed, append (or prepend) the commit message with [skip ci]
. The Git docs is pretty bare here but here's the hooks page: https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks。
希望对您有所帮助。
-里卡多
开发布道者,CircleCI
我想设置一个 CI 以便它仅在 git 提交被 GitHub webhooks 报告时做出反应和构建,包含我的子文件夹中任何内容的更改回购。
myRepo
> code1.js
> workers <-- run when this ... or anything under this changes
> worker1.js
例如,我想设置一个可以查看提交的 CircleCI 构建和 运行 一个脚本来根据提交变更日志决定 go? or no-go?
构建匹配在更改日志负载中搜索 workers
的正则表达式。
我只是不知道在哪里挂钩以及如何:
- 我是否应该设置我的 github webhook 以某种方式更智能并辨别更新日志是否有任何提及
workers
文件夹的内容?这样我的 CI 就可以保持沉默,因为 webhook 会自行决定何时将提交有效负载推送到 CI。 - 我是否应该以某种方式挂接到 CircleCI 的 yaml 文件中,以辨别变更日志是否有任何提及
workers
文件夹的内容?如果是,在哪里?
我可以编写自己的正则表达式,但我需要知道在哪里 inject/hook-in 脚本。
我不要求的东西:
- 我不要求 git 子模块 等替代方案
- 我不想分成两个单独的存储库
CircleCI 不支持内置此功能。在 CircleCI 方面,您肯定可以在 circle.yml
中有一些逻辑来检查 workers
目录中的更改,但是我们只会在构建过程开始后才对其进行评估。效率不高。
至于 GitHub webhooks,我不知道可以做这样的事情。如果是这样,那就太棒了,请告诉我。
我的建议
CircleCI 确实支持 [skip ci] or [ci skip]
flag in the commit message. If changes outside of the workers
directory is infrequent, simply add that flag to the commit message. If changes happen often, that'll be tedious so instead I'd use the Git commit-msg
hook. You can write a small script for that hook to check which directories contained changes. If anything inside workers/*
wasn't changed, append (or prepend) the commit message with [skip ci]
. The Git docs is pretty bare here but here's the hooks page: https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks。
希望对您有所帮助。
-里卡多
开发布道者,CircleCI