Skip to content

Commit

Permalink
feat: ✨ remove repo from installation collection upon uninstallation
Browse files Browse the repository at this point in the history
  • Loading branch information
slugb0t committed Jul 7, 2024
1 parent 33a1830 commit 83c610d
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions bot/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,24 @@ export default async (app) => {
}
});

app.on("installation.deleted", async (context) => {
const installationCollection = db.collection("installation");

for (const repository of context.payload.repositories) {
// Check if the installation is already in the database
const installation = await installationCollection.findOne({
repositoryId: repository.id,
});

if (installation) {
// Remove from the database
await installationCollection.deleteOne({
repositoryId: repository.id,
});
}
}
});

// When a push is made to a repository
app.on("push", async (context) => {
// Event for when a push is made to the repository (listens to all branches)
Expand Down

0 comments on commit 83c610d

Please sign in to comment.