Skip to content

Commit

Permalink
fix: publish error
Browse files Browse the repository at this point in the history
  • Loading branch information
alkoleft committed Jun 3, 2024
1 parent b54cac8 commit 9faf31d
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 32 deletions.
36 changes: 20 additions & 16 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

36 changes: 21 additions & 15 deletions src/github/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import * as core from '@actions/core'

import { Endpoints } from '@octokit/types'
import { Repo } from 'src/model/entity'
import { PullRequestEvent } from '@octokit/webhooks-definitions/schema'

export type IssueComment =
Endpoints['GET /repos/{owner}/{repo}/issues/comments']['response']['data'][0]
Expand Down Expand Up @@ -56,7 +57,7 @@ export class GithubMerge {
body: string,
params: GitReviewParam[]
): Promise<Review | null> {
core.debug(`createReviewComments ${JSON.stringify(params)}`)
core.debug(`createReviewComments`)

const comments: any = []
for (const i in params) {
Expand All @@ -72,13 +73,17 @@ export class GithubMerge {
return null
}

const response = await this.octokit.rest.pulls.createReview({
const commandParams = {
...this.repo,
pull_number: this.pull_number,
body: body,
commit_id: headSha()
}
core.debug('createReview' + JSON.stringify(commandParams))
const response = await this.octokit.rest.pulls.createReview({
...commandParams,
event: 'COMMENT',
comments: comments,
commit_id: github.context.sha
body: body,
comments: comments
})
return response.data
}
Expand All @@ -89,7 +94,7 @@ export class GithubMerge {
review_id: review_id,
pull_number: this.pull_number,
body: body,
commit_id: github.context.sha
commit_id: headSha()
})
}

Expand All @@ -98,7 +103,7 @@ export class GithubMerge {
...this.repo,
pull_number: this.pull_number,

commit_id: review.commit_id || '',
commit_id: headSha(),
body: comment.comment,
path: comment.path,
line: comment.line
Expand Down Expand Up @@ -127,7 +132,7 @@ export class GithubMerge {
body: comment.comment,
path: comment.path,
line: comment.line,
commit_id: github.context.sha
commit_id: headSha()
})

return response.data
Expand Down Expand Up @@ -187,17 +192,18 @@ export class GithubMerge {
}
}

function headSha() {
return pullRequestContext().pull_request.head.sha
}

function pullRequestContext(): PullRequestEvent {
return github.context.payload as PullRequestEvent
}

export interface GitReviewParam {
key: string
comment: string
path: string
line: number
[key: string]: any
}

export function forceCast<T>(input: any): T {
// ... do runtime checks here

// @ts-ignore <-- forces TS compiler to compile this as-is
return input
}

0 comments on commit 9faf31d

Please sign in to comment.