From 58a50bcf1426ab76f1e34d5d8e10db1e193a77e3 Mon Sep 17 00:00:00 2001 From: Aditya Choudhari Date: Sun, 27 Oct 2024 12:54:51 -0700 Subject: [PATCH] remove unused file --- apps/event-worker/src/job-sync/github.ts | 53 ------------------------ 1 file changed, 53 deletions(-) delete mode 100644 apps/event-worker/src/job-sync/github.ts diff --git a/apps/event-worker/src/job-sync/github.ts b/apps/event-worker/src/job-sync/github.ts deleted file mode 100644 index fd6426ce..00000000 --- a/apps/event-worker/src/job-sync/github.ts +++ /dev/null @@ -1,53 +0,0 @@ -import type { Job } from "@ctrlplane/db/schema"; - -import { eq } from "@ctrlplane/db"; -import { db } from "@ctrlplane/db/client"; -import { job } from "@ctrlplane/db/schema"; -import { configSchema } from "@ctrlplane/validators/github"; -import { JobStatus } from "@ctrlplane/validators/jobs"; - -import { convertStatus, getInstallationOctokit } from "../github-utils.js"; - -export const syncGithubJob = async (je: Job) => { - if (je.externalId == null) { - await db.update(job).set({ - status: JobStatus.ExternalRunNotFound, - message: `Run ID not found for job ${je.id}`, - }); - return; - } - - const runId = Number(je.externalId); - - const config = je.jobAgentConfig; - const parsed = configSchema.safeParse(config); - - if (!parsed.success) { - await db.update(job).set({ - status: JobStatus.InvalidJobAgent, - message: parsed.error.message, - }); - return; - } - - const octokit = getInstallationOctokit(parsed.data.installationId); - if (octokit == null) { - await db.update(job).set({ - status: JobStatus.InvalidJobAgent, - message: "GitHub bot not configured", - }); - return; - } - - const { data: workflowState } = await octokit.actions.getWorkflowRun({ - owner: parsed.data.owner, - repo: parsed.data.repo, - run_id: runId, - }); - - const status = convertStatus(workflowState.status ?? JobStatus.Pending); - - await db.update(job).set({ status }).where(eq(job.id, je.id)); - - return status === JobStatus.Completed; -};