在 github 操作中读取推送的命令行参数
我有一个在推送时执行的工作流程。有什么方法可以从推送命令中读取一些标志吗?因此,我将在本地计算机上像这样推送
git push origin my-branch --do-something
我想传递标志(如果可用)--do-something
,因为它就像我的操作一样
...
- name: Custom cmd
run: yarn my:script:cmd --do-something # its passed here
...
I have a workflow which is executed on push. Is there any way to read some flags from the push command? So, I will push like this on my local computer
git push origin my-branch --do-something
I want to pass the flag (if available) --do-something
as it is into my Action like
...
- name: Custom cmd
run: yarn my:script:cmd --do-something # its passed here
...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
恐怕这样是不可能的。
根据您确切需要触发的内容以及您想要传递的复杂程度,最常见的解决方案是:
基于
标签触发工作流程
并将选项编码到标签本身中 - 例如识别工作流程是否应通过使用正确的标签格式进行公开或内部构建。在消息提交中传递信息。您可以在 GIT 消息中将命令编码为 [-do-something],然后在工作流程中解析它。
例如:
使用 GitHub 中的dispatch_workflow事件直接触发所需的工作流程,其中所有可能的输入(可能是最灵活的)都可以与提交后挂钩集成。
I am afraid it's not possible like this.
Depending on what you exactly need to trigger and how complicated things you want to pass, the most common solutions are:
Trigger workflows based on
tags
and encode options into tags themselves - so for example to identify if workflow should make public or internal build, by having the proper format of tag.Pass information in message commit. You can encode the command as [-do-something] in GIT message and then parse it inside the workflow.
For example:
Use dispatch_workflow event in GitHub to directly trigger desired workflow with all possible inputs - probably most flexible - could be integrated with post-commit hooks.