Skip to content

Commit 2afd891

Browse files
committed
Use repo gettter
1 parent d56f977 commit 2afd891

File tree

2 files changed

+6
-14
lines changed

2 files changed

+6
-14
lines changed

dist/index.js

+3-7
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ const createCheck = async function (octokit, owner, repo, title, ref) {
314314
})
315315
return checkRunId
316316
} catch (err) {
317-
if (err === 'HttpError: Not Found') {
317+
if (err.message === 'Not Found') {
318318
throw new GitHubApiUnauthorizedError(`Unable to create a check, please make sure that the provided 'repo-token' has write permissions to ${owner}/${repo} - cause: ${err}`)
319319
}
320320
throw new GitHubApiError(`Unable to create a check to ${owner}/${repo} - cause: ${err}`)
@@ -393,15 +393,11 @@ async function run () {
393393

394394
const octokit = new github.getOctokit(repoToken)
395395
const ref = github.context.sha
396-
const owner = github.context.payload.repository.owner.name
397-
const repo = github.context.payload.repository.name
396+
const owner = github.context.repo.owner
397+
const repo = github.context.repo.repo
398398

399399
const inputContent = await fs.readFile(inputPath, 'utf8')
400400
const annotations = JSON.parse(inputContent)
401-
core.info(`owner ${owner}`)
402-
core.info(`repo ${repo}`)
403-
core.info(`github.context.payload.repository.owner ${github.context.payload.repository.owner}`)
404-
core.info(`github.context.payload.repository ${github.context.payload.repository}`)
405401
const checkRunId = await createCheck(octokit, owner, repo, title, ref)
406402
const { failureCount, warningCount, noticeCount } = stats(annotations)
407403
const summary = generateSummary(failureCount, warningCount, noticeCount)

index.js

+3-7
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const createCheck = async function (octokit, owner, repo, title, ref) {
4141
})
4242
return checkRunId
4343
} catch (err) {
44-
if (err === 'HttpError: Not Found') {
44+
if (err.message === 'Not Found') {
4545
throw new GitHubApiUnauthorizedError(`Unable to create a check, please make sure that the provided 'repo-token' has write permissions to ${owner}/${repo} - cause: ${err}`)
4646
}
4747
throw new GitHubApiError(`Unable to create a check to ${owner}/${repo} - cause: ${err}`)
@@ -120,15 +120,11 @@ async function run () {
120120

121121
const octokit = new github.getOctokit(repoToken)
122122
const ref = github.context.sha
123-
const owner = github.context.payload.repository.owner.name
124-
const repo = github.context.payload.repository.name
123+
const owner = github.context.repo.owner
124+
const repo = github.context.repo.repo
125125

126126
const inputContent = await fs.readFile(inputPath, 'utf8')
127127
const annotations = JSON.parse(inputContent)
128-
core.info(`owner ${owner}`)
129-
core.info(`repo ${repo}`)
130-
core.info(`github.context.payload.repository.owner ${github.context.payload.repository.owner}`)
131-
core.info(`github.context.payload.repository ${github.context.payload.repository}`)
132128
const checkRunId = await createCheck(octokit, owner, repo, title, ref)
133129
const { failureCount, warningCount, noticeCount } = stats(annotations)
134130
const summary = generateSummary(failureCount, warningCount, noticeCount)

0 commit comments

Comments
 (0)