Skip to content

Commit a76e34b

Browse files
committed
Add a script to remove unwanted installations
Every once in a while, somebody installs the GitForWindowsHelper GitHub App on their repository. Seeing as we have checks that ensure that only webhook events from the intended repositories are handled, this does not affect those repositories at all. However, it does send a ton of webhook events to those repositories, and when I go looking in https://github.com/organizations/git-for-windows/settings/apps/gitforwindowshelper/advanced for any specific delivery (e.g. to see the response from the Azure Function App in case something went wrong), it is incredibly tedious to click "Load more deliveries" a thousand times until I finally get to the interesting webhook event delivery. Let's avoid that by simply running (manually) this script from time to time, to uninstall the App on unintended repositories, to avoid those unnecessary and unwanted webhook deliveries. This script requires the same `local.settings.json` file as is needed for testing the Azure Function locally (for details, refer to `README.md#run-the-azure-function-locally`); That is where it gets the credentials required to perform the uninstallations. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent 11796c6 commit a76e34b

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

delete-bogus-installations.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
(async () => {
2+
const fs = require('fs')
3+
4+
const localSettings = JSON.parse(fs.readFileSync('local.settings.json'))
5+
process.env.GITHUB_APP_ID = localSettings.Values.GITHUB_APP_ID
6+
process.env.GITHUB_APP_PRIVATE_KEY = localSettings.Values.GITHUB_APP_PRIVATE_KEY
7+
8+
const gitHubRequestAsApp = require('./GitForWindowsHelper/github-api-request-as-app')
9+
const answer = await gitHubRequestAsApp(console, 'GET', '/app/installations?per_page=100')
10+
for (const e of answer.filter(e => e.account.login !== 'git-for-windows' && e.account.login !== 'dscho')) {
11+
console.log(`Deleting installation ${e.id} for ${e.account.login}`)
12+
await gitHubRequestAsApp(console, 'DELETE', `/app/installations/${e.id}`)
13+
}
14+
})().catch(console.log)

0 commit comments

Comments
 (0)