Skip to content

Commit

Permalink
chore: check repo name when retrieving files
Browse files Browse the repository at this point in the history
  • Loading branch information
galargh committed Aug 24, 2022
1 parent 4b0e262 commit 715f4b3
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions scripts/src/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 715f4b3

Please sign in to comment.