Working with monorepos
After connecting your Git provider to Port, Port will automatically create an entity for each repository in the organization in which you installed the integration.
If you're working with a monorepo and would like to create an entity for each microservice in a single repository instead, you can do that by making an adjustment to your Git integration's mapping:
- Go to the data-sources page of your portal.
- Under
Exporters
, click on the Git provider you would like to edit, for example:
- A window will open with a YAML mapping of the integration.
Use the following snippet as needed for your use-case (either add thefolder
entry to theresources
array, or replace the entire YAML with it):
In the snippet below, change the path
and repos
fields to your desired values before copying.
- GitHub
- GitLab
- BitBucket
- Azure DevOps (coming soon)
resources:
- kind: folder
selector:
query: "true" # JQ boolean query. If evaluated to false - skip syncing the object.
folders: # Specify the repositories and folders to include under this relative path.
- path: apps/* # Relative path to the folders within the repositories.
repos: # List of repositories to include folders from.
- backend-service
- frontend-service
port:
entity:
mappings:
identifier: ".folder.name"
title: ".folder.name"
blueprint: '"service"'
properties:
url: .repo.html_url + "/tree/" + .repo.default_branch + "/" + .folder.path
readme: file://README.md
resources:
- kind: folder
selector:
query: "true" # JQ boolean query. If evaluated to false - skip syncing the object.
folders: # Specify the repositories and folders to include under this relative path.
- path: "apps/" # Relative path to the folders within the repositories.
repos: # List of repositories to include folders from.
- backend-service
- frontend-service
port:
entity:
mappings:
identifier: .folder.name
title: .folder.name
blueprint: '"service"'
properties:
url: >-
.repo.web_url + "/tree/" + .repo.default_branch + "/" +
.folder.path
language: .repo.__languages | to_entries | max_by(.value) | .key
readme: file://README.md
resources:
- kind: folder
selector:
query: "true" # JQ boolean query. If evaluated to false - skip syncing the object.
folders: # Specify the repositories and folders to include under this relative path.
- path: apps/* # Relative path to the folders within the repositories.
repos: # List of repositories to include folders from.
- backend-service
- frontend-service
port:
entity:
mappings:
identifier: .folder.name
blueprint: '"service"'
properties:
url: .repo.links.html.href + "/src/" + .repo.mainbranch.name + "/" + .folder.path
readme: file://README.md
Currently monorepo support is available for the Git providers listed below.
Support for Azure DevOps is coming soon. Stay tuned!
-
Click on
Resync
to apply the changes. -
Head back to your catalog, as you can see Port has now created an entity for each folder in the specified repositories, instead of creating an entity for each repository.