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?
Reusing workflows in GitHub Actions is available in public beta now:
To summarize, the workflow that has to be reused needs workflow_call
trigger. The caller workflows can then refer it directly within a job by using uses
keyword as shown in the following example which is quoted directly from the GitHub page.
jobs:
call-workflow-1:
uses: octo-org/this-repo/.github/workflows/workflow-1.yml@172239021f7ba04fe7327647b213799853a9eb89
call-workflow-2:
uses: octo-org/another-repo/.github/workflows/workflow-2.yml@v1
It does have some limitations though.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With