Skip to content

Commit

Permalink
fix: try use more sane sha assignment
Browse files Browse the repository at this point in the history
  • Loading branch information
Codex- committed Sep 22, 2024
1 parent f9e0c69 commit c9285e3
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export async function listCommentIds(
continue;
}

if (body?.includes(cfgCommentId)) {
if (body.includes(cfgCommentId)) {
messageIds.push(id);
}
}
Expand Down Expand Up @@ -118,16 +118,21 @@ export async function deleteComment(commentId: number): Promise<DeleteCommentRes

type CreateCheckResponse = Awaited<ReturnType<Octokit["rest"]["checks"]["create"]>>;
export async function createCheck(name: string, title: string): Promise<CreateCheckResponse> {
if (github.context.payload.pull_request?.head.sha === undefined) {
let headSha: string = github.context.sha;
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
if (github.context.payload.pull_request?.head?.sha === undefined) {
core.warning("Unable to find correct head_sha from payload, using base context sha");
} else {
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
headSha = github.context.payload.pull_request.head.sha as string;
}

// https://docs.github.com/en/rest/checks/runs#create-a-check-run
const response = await octokit.rest.checks.create({
owner: github.context.repo.owner,
repo: github.context.repo.repo,
name: name,
head_sha: github.context.payload.pull_request?.head.sha ?? github.context.sha,
head_sha: headSha,
status: "in_progress",
output: {
title: title,
Expand Down

0 comments on commit c9285e3

Please sign in to comment.