如何共享/扩展/重用/引用GitHub工作流? [英] How to share/extend/reuse/reference GitHub Workflow?
问题描述
我有两个工作流程.一个人部署就可以掌握测试环境.另一个部署在产品环境中.它们是90%相同的代码复制和粘贴.
I have two workflows. One deploys on push to master to a test environment. The other deploys on release to prod environment. They are 90% identical, code copy&paste.
是否存在诸如提取部分重复逻辑并将其放入其自己的文件/部分/片段的概念?
Is there a concept such as extracting part of the duplicate logic and putting it into its own file/partial/fragment?
推荐答案
目前,无法在另一个工作流程中重用一个工作流程YAML.
At this time, reusing one workflow YAML in another, is not possible.
(在)多个地方对此进行了讨论:
This is (was) discussed in several places:
- How to reuse a whole workflow?
- Is it possible to reuse workflow yaml to setup similar workflows?
- Support for YAML anchors
对于您的特定问题,并非所有希望都消失了.
As for your particular problem, not all hope is lost.
我一直在使用 Kojo -一种从模板生成文件的命令行实用程序-正是为此目的.我有一个模板文件,并且生成了两个工作流程-一个用于阶段,一个用于生产.在从GitHub获得更正式的解决方案之前,它可能对您有用.
I have been using Kojo - a command line utility that generates files from templates - for exactly this purpose. I have one template file and I generate two workflows - one for stage, one for production. Perhaps it will be of use to you until a more formal solution from GitHub is available.
(免责声明:我是Kojo的作者).
(Disclaimer: I am Kojo's author).
这篇关于如何共享/扩展/重用/引用GitHub工作流?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!