问题
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