How to share/extend/reuse/reference GitHub Workflow?

懵懂的女人 提交于 2020-08-09 19:33:50

问题


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?


回答1:


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.

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.

(Disclaimer: I am Kojo's author).



来源:https://stackoverflow.com/questions/61688358/how-to-share-extend-reuse-reference-github-workflow

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!