123 lines · 4.5 KB
import { matchesFilters } from "~/lib/glob";
import type { ExprValue } from "./expressions";
import type { RefFilters, WorkflowSpec } from "./spec";
import type { RepoRow } from "~/lib/types";

const DEFAULT_PR_TYPES = ["opened", "synchronize", "reopened"];
const DEFAULT_RELEASE_TYPES = ["published"];
const DEFAULT_WORKFLOW_RUN_TYPES = ["completed"];

export type TriggerEvent =
  | "push"
  | "pull_request"
  | "release"
  | "workflow_dispatch"
  | "schedule"
  | "issues"
  | "issue_comment"
  | "pull_request_review"
  | "workflow_run"
  | "create"
  | "delete";

export type Trigger = {
  event: TriggerEvent;
  action: string | null;
  ref: string;
  sha: string;
  actorId: string | null;
  actorName: string;
  title: string;
  prNumber: number | null;
  headRef: string | null;
  baseRef: string | null;
  changedPaths: string[] | null;
  inputs: Record<string, ExprValue>;
  workflowPath: string | null;
  /** Repository whose objects are checked out (differs from `repo` for fork pull requests). */
  sourceRepo: RepoRow;
  /** Webhook-style payload exposed as `github.event`. */
  payload?: Record<string, ExprValue>;