DRY/Re-usable job steps for multiple workflows

I have 3 different workflows which have the same job steps. Something like below:

workflows:
 version: 2
 infra-region-1:
   when:
       region is 1
   jobs:
      - a
      - b
      - c
 infra-region-2:
   when:
       region is 2
   jobs:
      - a
      - b
      - c     
 infra-region-3:
   when:
       region is 3
   jobs:
      - a
      - b
      - c

Is there anyway that I can do DRY for the jobs section? Just declare it once somewhere and reference it?

Yes, by means of a YAML anchor

jobs_suite: &jobs_suite
  - a
  - b
  - c

infra-region-1:
  jobs: *jobs_suite
2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.