| 5 | import { RestEndpointMethodTypes } from "@octokit/plugin-rest-endpoint-methods"; |
| 6 | |
| 7 | async function getLivePullConfig( |
| 8 | octokit: ProbotOctokit, |
| 9 | log: Logger, |
| 10 | jobData: SchedulerJobData, |
| 11 | ): Promise<PullConfig | null> { |
| 12 | log.debug(`⚙️ Fetching live config`); |
| 13 | |
| 14 | const { owner, repo } = jobData; |
| 15 | |
| 16 | const { config } = await octokit.config.get({ |
| 17 | owner, |
| 18 | repo, |
| 19 | path: `.github/${appConfig.configFilename}`, |
| 20 | }); |
| 21 | |
| 22 | // Log config if found |
| 23 | if (!config || !config.version) { |
| 24 | log.warn("⚠️ No config found"); |
| 25 | return null; |
| 26 | } else { |
| 27 | log.info({ config }, "⚙️ Config found"); |
| 28 | } |
| 29 | |
| 30 | const result = pullConfigSchema.safeParse(config); |
| 31 | if (!result.success) { |
| 32 | throw new Error("Invalid config"); |
| 33 | } |
| 34 | |
| 35 | return result.data; |
| 36 | } |
| 37 | |
| 38 | function getDefaultPullConfig( |
| 39 | repository: RestEndpointMethodTypes["repos"]["get"]["response"]["data"], |