Skip to content

Commit d66d9de

Browse files
committed
fixes: github#782
1 parent 9dbe6c7 commit d66d9de

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

index.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -221,12 +221,14 @@ module.exports = (robot, { getRouter }, Settings = require('./lib/settings')) =>
221221
github.apps.listInstallations.endpoint.merge({ per_page: 100 })
222222
)
223223
robot.log.debug(`installations: ${JSON.stringify(installations)}`)
224-
if (installations.length > 0) {
225-
const installation = installations[0]
224+
const installation = installations.find(inst => inst.account.login === env.GH_ORG)
225+
if (installation) {
226226
const github = await robot.auth(installation.id)
227227
const app = await github.apps.getAuthenticated()
228228
appSlug = app.data.slug
229229
robot.log.debug(`Validated the app is configured properly = \n${JSON.stringify(app.data, null, 2)}`)
230+
} else {
231+
robot.log.error(`No installation found for organization: ${env.GH_ORG}`)
230232
}
231233
}
232234

@@ -238,8 +240,8 @@ module.exports = (robot, { getRouter }, Settings = require('./lib/settings')) =>
238240
github.apps.listInstallations.endpoint.merge({ per_page: 100 })
239241
)
240242

241-
if (installations.length > 0) {
242-
const installation = installations[0]
243+
const installation = installations.find(inst => inst.account.login === env.GH_ORG)
244+
if (installation) {
243245
const github = await robot.auth(installation.id)
244246
const context = {
245247
payload: {
@@ -250,6 +252,8 @@ module.exports = (robot, { getRouter }, Settings = require('./lib/settings')) =>
250252
repo: () => { return { repo: env.ADMIN_REPO, owner: installation.account.login } }
251253
}
252254
return syncAllSettings(false, context)
255+
} else {
256+
robot.log.error(`No installation found for organization: ${env.GH_ORG}`)
253257
}
254258
return null
255259
}

0 commit comments

Comments
 (0)