minder
minder copied to clipboard
Add logic for handling added repositories to the GitHub App webhook handler
On adding a new repository we would receive a webhook message that a new repository was added. The message looks like this:
{
"action": "added",
"installation": {
"id": 49896345,
"account": {
"login": "jakubtestorg",
"id": 142222776,
"node_id": "O_kgDOCHoluA",
"avatar_url": "https://avatars.githubusercontent.com/u/142222776?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/jakubtestorg",
...
},
...
"app_id": 864067,
"app_slug": "jakub-s-local-minder-test",
},
"events": [],
"created_at": "2024-04-22T14:16:52.000+02:00",
"updated_at": "2024-04-22T14:16:53.000+02:00",
},
"repository_selection": "all",
"repositories_added": [
{
"id": 790254972,
"node_id": "R_kgDOLxpVfA",
"name": "newrepo2",
"full_name": "jakubtestorg/newrepo2",
"private": false
}
],
After receiving such request we need to:
- Check that we know the installation ID and infer the project ID
- Route the repositories from repositories_added or repositories_deleted to the appropriate handler. For deletion we already have handleEntityDeleteEvent, we need to add a similar handleEntityAddedEvent
- The handler would create or remove the repository record in the database
- In case the repository was added, also create the webhook. Once the repository is created, Minder issues an event to reconcile it with the profiles in that project.