GitHub
Our integration with GitHub allows you to export GitHub objects to Port as entities of existing blueprints. The integration supports real-time event processing so Port always provides an accurate real-time representation of your GitHub resources.
💡 GitHub integration common use cases​
Our GitHub integration makes it easy to fill the software catalog with data directly from your GitHub organization, for example:
- Map all the resources in your GitHub organization, including services, pull requests, workflows, workflow runs, teams, dependabot alerts, deployment environments and other GitHub objects.
- Watch for GitHub object changes (create/update/delete) in real-time, and automatically apply the changes to your entities in Port.
- Manage Port entities using GitOps.
- Trigger GitHub workflows directly from Port.
Installation​
To install Port's GitHub app, follow the installation guide.
Ingesting Git objects​
By using Port's GitHub app, you can automatically ingest GitHub resources into Port based on real-time events.
The app allows you to ingest a variety of objects resources provided by the GitHub API, including repositories, pull requests, workflows and more. It also allows you to perform "extract, transform, load (ETL)" on data from the GitHub API into the desired software catalog data model.
The GitHub app uses a YAML configuration file to describe the ETL process to load data into the developer portal. The approach reflects a golden middle between an overly opinionated Git visualization that might not work for everyone and a too-broad approach that could introduce unneeded complexity into the developer portal.
After installing the app, Port will automatically create a service
blueprint in your catalog (representing a GitHub repository), along with a default YAML configuration file that defines where the data fetched from Github's API should go in the blueprint.
Configuration​
To ingest GitHub objects, use one of the following methods:
- Using Port's UI
- Using GitHub
To manage your GitHub integration configuration using Port:
- Go to the data sources page of your portal.
- Under
Exporters
, click on your desired GitHub organization. - A window will open containing the default YAML configuration of your GitHub integration.
- Here you can modify the configuration to suit your needs, by adding/removing entries.
- When finished, click
resync
to apply any changes.
Using this method applies the configuration to all repositories that the GitHub app has permissions to.
When configuring the integration using Port, the YAML configuration is global, allowing you to specify mappings for multiple Port blueprints.
To manage your GitHub integration configuration using GitHub, you can choose either a global or granular configuration:
- Global configuration: create a
.github-private
repository in your organization and add theport-app-config.yml
file to the repository.- Using this method applies the configuration to all repositories that the GitHub app has permissions to (unless it is overridden by a granular
port-app-config.yml
in a repository).
- Using this method applies the configuration to all repositories that the GitHub app has permissions to (unless it is overridden by a granular
- Granular configuration: add the
port-app-config.yml
file to the.github
directory of your desired repository.- Using this method applies the configuration only to the repository where the
port-app-config.yml
file exists.
- Using this method applies the configuration only to the repository where the
When using global configuration using GitHub, the configuration specified in the port-app-config.yml
file will only be applied if the file is in the default branch of the repository (usually main
).
When using Port, the specified configuration will override any other configuration source (both global configuration using GitHub and granular configuration using GitHub).
If you want to delete the configuration specified in Port and use Github instead, simply replace the mapping content in Port with null
, then click Save & resync
.
Here is an example snippet from the port-app-config.yml
file which demonstrates the ETL process for getting githubPullRequest
data from the GitHub organization and into the software catalog:
resources:
# Extract
- kind: pull-request
selector:
query: "true" # JQ boolean query. If evaluated to false - skip syncing the object.
port:
entity:
mappings:
# Transform & Load
identifier: ".head.repo.name + (.id|tostring)" # The Entity identifier will be the repository name + the pull request ID. After the Entity is created, the exporter will send `PATCH` requests to update this pull request within Port.
title: ".title"
blueprint: '"githubPullRequest"'
properties:
creator: ".user.login"
assignees: "[.assignees[].login]"
reviewers: "[.requested_reviewers[].login]"
status: ".status" # merged, closed, open
closedAt: ".closed_at"
updatedAt: ".updated_at"
mergedAt: ".merged_at"
prNumber: ".id"
link: ".html_url"
The app makes use of the JQ JSON processor to select, modify, concatenate, transform and perform other operations on existing fields and values from GitHub's API events.
port-app-config.yml
file​
The port-app-config.yml
file is how you specify the exact resources you want to query from your GitHub organization, and also how you specify which entities and which properties you want to fill with data from GitHub.
Note that when using Port's UI to configure the GitHub integration, port-app-config.yml
refers to the YAML editor window where you can modify the configuration.
Here is an example port-app-config.yml
block:
resources:
- kind: repository
selector:
query: "true" # JQ boolean query. If evaluated to false - skip syncing the object.
port:
entity:
mappings:
identifier: ".name" # The Entity identifier will be the repository name.
title: ".name"
blueprint: '"service"'
properties:
url: ".html_url"
description: ".description"
port-app-config.yml
structure​
-
The root key of the
port-app-config.yml
file is theresources
key:resources:
- kind: repository
selector:
... -
The
kind
key is a specifier for an object from the GitHub API:resources:
- kind: repository
selector:
...Available GitHub resources
Filtering unwanted objects​
The selector
and the query
keys let you filter exactly which objects from the specified kind
will be ingested into the software catalog:
resources:
- kind: repository
selector:
query: "true" # JQ boolean query. If evaluated to false - skip syncing the object.
port:
For example, to ingest only repositories that have a name starting with "service"
, use the query
key like this:
query: .name | startswith("service")
The port
, entity
and the mappings
keys open the section used to map the GitHub API object fields to Port entities. To create multiple mappings of the same kind, you can add another item to the resources
array:
resources:
- kind: repository
selector:
query: "true"
port:
entity:
mappings: # Mappings between one GitHub API object to a Port entity. Each value is a JQ query.
currentIdentifier: ".name" # OPTIONAL - keep it only in case you want to change the identifier of an existing entity from "currentIdentifier" to "identifier".
identifier: ".name"
title: ".name"
blueprint: '"service"'
properties:
description: ".description"
url: ".html_url"
defaultBranch: ".default_branch"
- kind: repository # In this instance repository is mapped again with a different filter
selector:
query: '.name == "MyRepositoryName"'
port:
entity:
mappings: ...
Pay attention to the value of the blueprint
key, if you want to use a hardcoded string, you need to encapsulate it in 2 sets of quotes, for example use a pair of single-quotes ('
) and then another pair of double-quotes ("
)
Permissions​
Port's GitHub integration requires the following permissions:
-
Repository permissions:
- Actions: Read and Write (for executing self-service action using GitHub workflow).
- Administration: Readonly (for exporting repository teams)
- Checks: Read and Write (for validating
port.yml
). - Contents: Readonly.
- Metadata: Readonly.
- Issues: Readonly.
- Pull requests: Read and write.
- Dependabot alerts: Readonly.
- Deployments: Readonly.
- Environments: Readonly.
- Code scanning alerts: Readonly.
-
Organization permissions:
- Members: Readonly (for exporting organization teams).
- Administration: Readonly (for exporting organization users).
-
Repository events (required to receive changes via webhook from GitHub and apply the
port-app-config.yml
configuration on them):- Issues
- Pull requests
- Push
- Workflow run
- Team
- Dependabot Alerts
- Deployment
- Branch protection rule
- Code scanning alert
- Member
- Membership
You will be prompted to confirm these permissions when first installing the App.
Permissions can be given to select repositories in your organization, or to all repositories. You can reconfigure the app at any time, giving it access to new repositories, or removing access.
Examples​
Refer to the examples page for practical configurations and their corresponding blueprint definitions.
GitOps​
Port's GitHub app also provides GitOps capabilities, refer to the GitOps page to learn more.
Advanced​
Refer to the advanced page for advanced use cases and examples.
Self-hosted installation​
Port's GitHub app also supports a self-hosted installation, refer to the self-hosted installation page to learn more.