| 140 | const privateKey = Buffer.from(config.githubAppPrivateKey, 'base64').toString( |
| 141 | 'utf-8', |
| 142 | ) |
| 143 | |
| 144 | const app = new App({ |
| 145 | appId: config.githubAppId, |
| 146 | privateKey, |
| 147 | webhooks: { secret: config.githubWebhookSecret }, |
| 148 | }) |
| 149 | |
| 150 | const octokit = await app.getInstallationOctokit(payload.installation.id) |
| 151 | |
| 152 | const owner: string = payload.repository.owner.login |
| 153 | const repo: string = payload.repository.name |
| 154 | |
| 155 | let repoConfig: RepoConfig = DEFAULT_CONFIG |
| 156 | try { |
| 157 | const { data } = await octokit.rest.repos.getContent({ |
| 158 | owner, |
| 159 | repo, |
| 160 | path: '.github/agentscan.yml', |
| 161 | }) |
| 162 | |
| 163 | if ('content' in data) { |
| 164 | repoConfig = parseRepoConfig( |
| 165 | Buffer.from(data.content, 'base64').toString('utf-8'), |
| 166 | ) |
| 167 | } |