How to include yaml in other repo?

Now, I’m migrating our projects from gitlab to Github.
so, I’m creating circle-ci for the migrated service.
I have one question.
in the gitlab-ci, we can use ‘include’ to use the yaml file in the other repo.


This could reduce lots of configuration for whole service. because, we can reuse 1 yaml for whole services.
Is there any function like this in the circle-ci?

Hi @hiker and welcome to our developer’s forum!

You can reuse parts of configs by packing them as orbs. Orbs are reusable YAML snippets. You can see more information about orbs here: https://circleci.com/orbs/

So for example, CircleCI provides a Python orb that allows users to simply import jobs, commands, and executors instead of writing their own for common Python tasks. To use and reuse a test command, you could just import the orb then use the job as follows:

version: 2.1

orbs:
  python: circleci/python@1.0.0

workflows:
  main:
    jobs:
      - python/test:
          args: '--dev'
          pkg-manager: pipenv
          test-tool: pytest

The orb is actually named “circleci/python” with a version number. Then it’s aliased with a key, in this case “python”. You can then use the orb key to reference jobs (python/test) or executors (python/default).

While this is one of CircleCI’s certified orbs, you can author your own orb with the help of the orb development kit.