# GitHub Deployment Event

> GitHub deployment webhook payload with environment, ref, and creator tracking.

- Name: `github-deployment-event`
- Categories: github
- Depends on: `@open-types/github-shared`
- Detail page: https://open-types.dev/types/github-deployment-event

## Install

```bash
# Types only
npx shadcn add @open-types/github-deployment-event

# Types + Zod v4 validators
npx shadcn add @open-types/github-deployment-event-zod

# Types + real-world examples
npx shadcn add @open-types/github-deployment-event-examples
```

## Types

```typescript
import type {
  GitHubUser,
  GitHubRepository,
  GitHubOrganization,
} from "./github-shared";

export interface GitHubDeployment {
  url: string;
  id: number;
  node_id: string;
  sha: string;
  ref: string;
  task: string;
  environment: string;
  description: string | null;
  creator: GitHubUser;
  created_at: string;
  updated_at: string;
  payload: Record<string, unknown>;
}

export interface GitHubDeploymentEvent {
  action: "created";
  deployment: GitHubDeployment;
  repository: GitHubRepository;
  sender: GitHubUser;
  organization?: GitHubOrganization;
}
```

## Zod validator

```typescript
import * as z from "zod";
import type {
  GitHubDeployment,
  GitHubDeploymentEvent,
} from "../types/github-deployment-event";
import {
  githubUserSchema,
  githubRepositorySchema,
  githubOrganizationSchema,
} from "./github-shared";

export const githubDeploymentPayloadSchema = z.record(
  z.string(),
  z.unknown()
) satisfies z.ZodType<Record<string, unknown>>;

export const githubDeploymentActionSchema = z.enum([
  "created",
]) satisfies z.ZodType<GitHubDeploymentEvent["action"]>;

export const githubDeploymentSchema = z.object({
  url: z.string(),
  id: z.number().int(),
  node_id: z.string(),
  sha: z.string(),
  ref: z.string(),
  task: z.string(),
  environment: z.string(),
  description: z.string().nullable(),
  creator: githubUserSchema,
  created_at: z.string(),
  updated_at: z.string(),
  payload: githubDeploymentPayloadSchema,
}) satisfies z.ZodType<GitHubDeployment>;

export const githubDeploymentEventSchema = z.object({
  action: githubDeploymentActionSchema,
  deployment: githubDeploymentSchema,
  repository: githubRepositorySchema,
  sender: githubUserSchema,
  organization: githubOrganizationSchema.optional(),
}) satisfies z.ZodType<GitHubDeploymentEvent>;

export type {
  GitHubDeployment,
  GitHubDeploymentEvent,
} from "../types/github-deployment-event";
```

## Examples

```typescript
// Source: https://docs.github.com/en/webhooks/webhook-events-and-payloads#deployment
// Captured: 2026-05
import type {
  GitHubDeployment,
  GitHubDeploymentEvent,
} from "../types/github-deployment-event";
import {
  githubUserOctocat,
  githubRepositoryHelloWorld,
  githubOrganizationGitHub,
} from "./shared/github.examples";

const deployment = {
  url: "https://api.github.com/repos/octocat/Hello-World/deployments/42",
  id: 42,
  node_id: "MDEwOkRlcGxveW1lbnQxMA==",
  sha: "6dcb09b5b57875f334f61aebed695e2e4193db5e",
  ref: "main",
  task: "deploy",
  environment: "production",
  description: "Deploy to production",
  creator: githubUserOctocat,
  created_at: "2024-09-12T10:15:30Z",
  updated_at: "2024-09-12T10:15:32Z",
  payload: { auto_merge: false, required_contexts: [] as string[] },
} as const satisfies GitHubDeployment;

export const githubDeploymentExamples = {
  minimal: deployment,
  noDescription: { ...deployment, description: null } satisfies GitHubDeployment,
  emptyPayload: { ...deployment, payload: {} } satisfies GitHubDeployment,
  richPayload: {
    ...deployment,
    payload: {
      auto_merge: true,
      required_contexts: ["ci/test", "ci/lint"],
      transient_environment: false,
      production_environment: true,
    },
  } satisfies GitHubDeployment,
} as const;

const minimal = {
  action: "created",
  deployment,
  repository: githubRepositoryHelloWorld,
  sender: githubUserOctocat,
} as const satisfies GitHubDeploymentEvent;

export const githubDeploymentEventExamples = {
  minimal,
  full: { ...minimal, organization: githubOrganizationGitHub } satisfies GitHubDeploymentEvent,
} as const;
```
