* Creates an authenticated GitHub client from the handler configuration. * * If the handler config contains a "github-token" field, this function creates * a new Octokit instance authenticated with that token. This enables cross-repository * operations where a PAT with access to the target repo
(config)
| 38 | * Both return values expose the same API surface (rest, graphql, etc.). |
| 39 | */ |
| 40 | async function createAuthenticatedGitHubClient(config) { |
| 41 | // Note: bracket notation is required because "github-token" contains a hyphen |
| 42 | // (not a valid JavaScript identifier). This is consistent with other hyphenated |
| 43 | // config keys like "target-repo" and "allowed-repos". |
| 44 | const token = config["github-token"]; |
| 45 | if (!token) { |
| 46 | return github; |
| 47 | } |
| 48 | core.info("Using per-handler github-token for cross-repository authentication"); |
| 49 | return global.getOctokit(token); |
| 50 | } |
| 51 | |
| 52 | module.exports = { createAuthenticatedGitHubClient }; |
no outgoing calls
no test coverage detected