273 lines · 10.7 KB
import { env } from "cloudflare:workers";
import { first } from "../db";
import { repoDb } from "../scoped-db";
import { jobDb, runDb } from "./scope";
import { randomId } from "../crypto";
import { CAPS } from "../limits";
import { hasPermission, loadRepoById, repoPermission } from "../repos";
import { loadUserById, toViewer } from "../auth";
import { withStore } from "../git/store";
import { matchesFilters } from "~/lib/glob";
import { ENVIRONMENT_URL_OUTPUT } from "./compile";
import type { WorkflowJobRow, WorkflowRunRow } from "./jobs";
import type { Conclusion } from "~/lib/types";

export type EnvironmentRow = {
  id: string;
  repo_id: string;
  name: string;
  wait_timer_minutes: number;
  reviewers: string;
  branch_patterns: string;
  prevent_self_review: number;
  created_at: number;
};

export type DeploymentRow = {
  id: string;
  repo_id: string;
  environment_id: string;
  run_id: string;
  job_id: string;
  ref: string;
  sha: string;
  creator_id: string | null;
  status: "waiting" | "queued" | "in_progress" | "success" | "failure" | "cancelled" | "rejected";
  url: string | null;
  wait_until: number | null;
  reviewed_by: string | null;
  reviewed_at: number | null;
  created_at: number;