diff --git a/src/utils/config.ts b/src/utils/config.ts index ac990fe..806bea8 100644 --- a/src/utils/config.ts +++ b/src/utils/config.ts @@ -14,7 +14,11 @@ export const readConfig = async ( ): Promise => { const content: string = readFile(config, userConfigPath); - const remoteConfig: Config = await readRemoteConfig(repo, userConfigPath); + const remoteConfig: Config = await readRemoteConfig( + config, + repo, + userConfigPath, + ); if (content === "") { return merge(defaultConfig, remoteConfig, config); @@ -26,6 +30,7 @@ export const readConfig = async ( }; export const readRemoteConfig = async ( + config: Config, repo: Repository | undefined, filename: string, ): Promise => { @@ -34,10 +39,19 @@ export const readRemoteConfig = async ( return {}; } - const response: string = await repo.getRawFile(filename); + const response1: string = await repo.getRawFile(".github", filename); + + if (response1 !== "") { + return yaml.load(response1); + } + + const response2: string = await repo.getRawFile( + config.repository?.owner || ".github", + filename, + ); - if (response !== "") { - return yaml.load(response); + if (response2 !== "") { + return yaml.load(response2); } return {}; diff --git a/src/utils/repository.ts b/src/utils/repository.ts index bfe98c7..4e35710 100644 --- a/src/utils/repository.ts +++ b/src/utils/repository.ts @@ -202,13 +202,13 @@ export class Repository { } } - async getRawFile(filename: string): Promise { + async getRawFile(repo: string, filename: string): Promise { try { const response = await this._octokit.rest.repos.getContent(< RestEndpointMethodTypes["repos"]["getContent"]["parameters"] >{ owner: this._config.repository?.owner, - repo: ".github", + repo: repo, path: filename, headers: { Accept: "application/vnd.github.v3.raw",