From 715f4b3a93272b9e4f3e10c07fa7991259503ccf Mon Sep 17 00:00:00 2001 From: galargh Date: Wed, 24 Aug 2022 12:36:40 +0200 Subject: [PATCH] chore: check repo name when retrieving files --- scripts/src/github.ts | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/scripts/src/github.ts b/scripts/src/github.ts index 7b03cbb..0162ac5 100644 --- a/scripts/src/github.ts +++ b/scripts/src/github.ts @@ -190,13 +190,26 @@ export class GitHub { async getRepositoryFile(repository: string, path: string) { core.info(`Checking if ${repository}/${path} exists...`) try { - return ( - await this.client.repos.getContent({ + const repo = ( + await this.client.repos.get({ owner: env.GITHUB_ORG, - repo: repository, - path + repo: repository }) - ).data as {path: string; url: string} + ).data + if (repo.owner.login === env.GITHUB_ORG && repo.name === repository) { + return ( + await this.client.repos.getContent({ + owner: env.GITHUB_ORG, + repo: repository, + path + }) + ).data as {path: string; url: string} + } else { + core.debug( + `${env.GITHUB_ORG}/${repository} has moved to ${repo.owner.login}/${repo.name}` + ) + return undefined + } } catch (e) { core.debug(JSON.stringify(e)) return undefined