Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,14 @@ module.exports = (robot, { getRouter }, Settings = require('./lib/settings')) =>
github.apps.listInstallations.endpoint.merge({ per_page: 100 })
)
robot.log.debug(`installations: ${JSON.stringify(installations)}`)
if (installations.length > 0) {
const installation = installations[0]
const installation = installations.find(inst => inst.account.login === env.GH_ORG)
if (installation) {
const github = await robot.auth(installation.id)
const app = await github.apps.getAuthenticated()
appSlug = app.data.slug
robot.log.debug(`Validated the app is configured properly = \n${JSON.stringify(app.data, null, 2)}`)
} else {
robot.log.error(`No installation found for organization: ${env.GH_ORG}`)
}
}

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

if (installations.length > 0) {
const installation = installations[0]
const installation = installations.find(inst => inst.account.login === env.GH_ORG)
if (installation) {
const github = await robot.auth(installation.id)
const context = {
payload: {
Expand All @@ -250,6 +252,8 @@ module.exports = (robot, { getRouter }, Settings = require('./lib/settings')) =>
repo: () => { return { repo: env.ADMIN_REPO, owner: installation.account.login } }
}
return syncAllSettings(nop, context)
} else {
robot.log.error(`No installation found for organization: ${env.GH_ORG}`)
}
return null
}
Expand Down