Sync Github repositories deletion in real-time
Matan Grady
Currently if you delete a repo in Github, it's not synced in real-time to Port (unless you manually trigger a new sync).
Matan Grady
A possible workaround is to define a custom webhook -
- Set up Github webhooks for deleted repositories - https://docs.github.com/en/webhooks/webhook-events-and-payloads?actionType=deleted#repository
- Configure a new webhook in Port to delete the repo - https://docs.getport.io/build-your-software-catalog/custom-integration/webhook/#structure
Example event:
{
"action": "deleted",
"repository": {
"id": 1296269,
"name": "Hello-World",
"full_name": "octocat/Hello-World",
"html_url": "https://github.com/octocat/Hello-World"
}
}
Example mapping:
{
"identifier": "repositoryDeletionMapper",
"title": "Repository Deletion Mapper",
"enabled": true,
"mappings": [
{
"blueprint": "repository",
"operation": "delete",
"filter": ".headers.\"X-GitHub-Event\" == \"repository\" and .body.action == \"deleted\"",
"entity": {
"identifier": ".body.repository.full_name",
"title": ".body.repository.name"
}
}
],
"security": {
"secret": " {{ .secrets.github-webhook-secret }} ",
"signatureHeaderName": "X-Hub-Signature-256",
"signatureAlgorithm": "sha256",
"signaturePrefix": "sha256=",
"requestIdentifierPath": ".headers.\"X-GitHub-Delivery\""
}
}
Matan Grady
A possible workaround is to define a custom webhook -
- Set up Github webhooks for deleted repositories - https://docs.github.com/en/webhooks/webhook-events-and-payloads?actionType=deleted#repository
- Configure a new webhook in Port to delete the repo - https://docs.getport.io/build-your-software-catalog/custom-integration/webhook/#structure
Example event:
{
"action": "deleted",
"repository": {
"id": 1296269,
"name": "Hello-World",
"full_name": "octocat/Hello-World",
"html_url": "https://github.com/octocat/Hello-World"
}
}
Example mapping:
{
"identifier": "repositoryDeletionMapper",
"title": "Repository Deletion Mapper",
"enabled": true,
"mappings": [
{
"blueprint": "repository",
"operation": "delete",
"filter": ".headers.\"X-GitHub-Event\" == \"repository\" and .body.action == \"deleted\"",
"entity": {
"identifier": ".body.repository.full_name",
"title": ".body.repository.name"
}
}
],
"security": {
"secret": " {{ .secrets.github-webhook-secret }} ",
"signatureHeaderName": "X-Hub-Signature-256",
"signatureAlgorithm": "sha256",
"signaturePrefix": "sha256=",
"requestIdentifierPath": ".headers.\"X-GitHub-Delivery\""
}
}