This repository contains a GitHub Actions workflow and supporting Python script to:
- Extract plugins and their versions from a Gradle build file.
- Map the extracted plugins as package entities in Port.
- Automatically create or update a service entity in Port, connecting it to its plugin dependencies.
This workflow simplifies tracking dependencies for your services by automating the extraction and ingestion of Gradle plugin data into Port.
To authenticate with Port, you need to save your credentials as repository secrets in GitHub:
- Navigate to your GitHub repository.
- Go to Settings > Secrets and variables > Actions > New repository secret.
- Add the following secrets:
CLIENT_ID
: Your Port client ID.CLIENT_SECRET
: Your Port client secret.
Before running the workflow, ensure that the required blueprints are created in Port.
The Service blueprint represents your service and its relationships to dependencies. Use the following JSON to create the blueprint in Port:
{
"identifier": "service",
"title": "Service",
"icon": "Github",
"schema": {
"properties": {
"readme": {
"title": "README",
"type": "string",
"format": "markdown",
"icon": "Book"
},
"url": {
"title": "URL",
"format": "url",
"type": "string",
"icon": "Link"
},
"language": {
"type": "string",
"title": "Language",
"icon": "Git"
},
"slack": {
"icon": "Slack",
"type": "string",
"title": "Slack",
"format": "url"
},
"tier": {
"title": "Tier",
"type": "string",
"description": "How mission-critical the service is",
"enum": [
"Mission Critical",
"Customer Facing",
"Internal Service",
"Other"
],
"enumColors": {
"Mission Critical": "turquoise",
"Customer Facing": "green",
"Internal Service": "darkGray",
"Other": "yellow"
},
"icon": "DefaultProperty"
},
"gradle_file": {
"type": "string",
"title": "Gradle file"
}
},
"required": []
},
"mirrorProperties": {},
"calculationProperties": {},
"aggregationProperties": {},
"relations": {
"dependencies": {
"title": "Dependencies",
"target": "package",
"required": false,
"many": true
}
}
}
The Package blueprint represents each plugin as a dependency. Use the following JSON to create the blueprint in Port:
{
"identifier": "package",
"title": "Package",
"icon": "Package",
"schema": {
"properties": {
"package": {
"icon": "DefaultProperty",
"type": "string",
"title": "Package"
},
"version": {
"icon": "DefaultProperty",
"type": "string",
"title": "Version"
}
},
"required": [
"package",
"version"
]
},
"mirrorProperties": {},
"calculationProperties": {},
"aggregationProperties": {},
"relations": {}
}
Once the blueprints are set up and your Port credentials are saved as secrets, you’re ready to run the workflow.
- Navigate to the Actions tab in your GitHub repository.
- Select the "Extract and Upsert Gradle Plugins and Service to Port" workflow.
- Click Run workflow and provide the following input:
gradle_path
: The path to the Gradle build file. Default:./build.gradle
.
The workflow will:
- Parse the specified Gradle file.
- Extract plugins and their versions.
- Upsert the
service
andpackage
entities into Port, linking the service to its dependencies.
Here’s an example Gradle file to test the workflow:
plugins {
id 'org.springframework.boot' version '3.1.2'
id 'com.github.spotbugs' version '5.0.13'
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter'
testImplementation 'org.junit.jupiter:junit-jupiter'
}
After the workflow runs, you’ll see:
- A service entity in Port, named after your GitHub repository (e.g.,
my-repo
), with a relation to: - Package entities for each Gradle plugin extracted from the build file.
This integration helps you track dependencies for your services efficiently.