Add lenient review check action
This commit is contained in:
1 parent
63eba2db87
commit
5cca2e8564
6 files changed
+153
-21
No files matched your search
@@ -2,7 +2,7 @@ import { Webhooks } from "@octokit/webhooks";
|
||||
import { config } from "../config.js";
|
||||
import { getInstallationOctokit } from "./app.js";
|
||||
import { logger } from "../logger.js";
|
||||
import { processPullRequest } from "../review/processor.js";
|
||||
import { isLenientCheckAction, processLenientCheckRunAction, processPullRequest } from "../review/processor.js";
|
||||
|
||||
export function createGitHubWebhooks(): Webhooks {
|
||||
const webhooks = new Webhooks({
|
||||
@@ -22,12 +22,31 @@ export function createGitHubWebhooks(): Webhooks {
|
||||
await processPullRequest(octokit, {
|
||||
owner: payload.repository.owner.login,
|
||||
repo: payload.repository.name,
|
||||
pullNumber: payload.pull_request.number,
|
||||
installationId
|
||||
pullNumber: payload.pull_request.number
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
webhooks.on("check_run.requested_action", async ({ payload }) => {
|
||||
const actionIdentifier = payload.requested_action?.identifier;
|
||||
if (!actionIdentifier || !isLenientCheckAction(actionIdentifier)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const installationId = payload.installation?.id;
|
||||
if (!installationId) {
|
||||
logger.warn({ repository: payload.repository.full_name, checkRun: payload.check_run.id }, "Skipping check action without installation id.");
|
||||
return;
|
||||
}
|
||||
|
||||
const octokit = await getInstallationOctokit(installationId);
|
||||
await processLenientCheckRunAction(octokit, {
|
||||
owner: payload.repository.owner.login,
|
||||
repo: payload.repository.name,
|
||||
headSha: payload.check_run.head_sha
|
||||
});
|
||||
});
|
||||
|
||||
webhooks.onError((error) => {
|
||||
logger.error({ error }, "Webhook handler failed.");
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user