# GitHub Shared

> Common GitHub webhook types: User, Repository, Organization, Label, Milestone, and AuthorAssociation.

- Name: `github-shared`
- Categories: github
- Detail page: https://open-types.dev/types/github-shared

## Install

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

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

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

## Types

```typescript
export interface GitHubUser {
  login: string;
  id: number;
  node_id: string;
  avatar_url: string;
  url: string;
  html_url: string;
  type: string;
  site_admin: boolean;
}

export interface GitHubRepository {
  id: number;
  node_id: string;
  name: string;
  full_name: string;
  private: boolean;
  owner: GitHubUser;
  html_url: string;
  description: string | null;
  fork: boolean;
  url: string;
  default_branch: string;
}

export interface GitHubOrganization {
  login: string;
  id: number;
  node_id: string;
  url: string;
  avatar_url: string;
  description: string | null;
}

export interface GitHubLabel {
  id: number;
  node_id: string;
  url: string;
  name: string;
  color: string;
  description: string | null;
  default: boolean;
}

export type GitHubMilestoneState = "open" | "closed";

export interface GitHubMilestone {
  id: number;
  node_id: string;
  number: number;
  title: string;
  description: string | null;
  state: GitHubMilestoneState;
  open_issues: number;
  closed_issues: number;
  created_at: string;
  updated_at: string;
  closed_at: string | null;
  due_on: string | null;
}

export type GitHubAuthorAssociation =
  | "COLLABORATOR"
  | "CONTRIBUTOR"
  | "FIRST_TIMER"
  | "FIRST_TIME_CONTRIBUTOR"
  | "MANNEQUIN"
  | "MEMBER"
  | "NONE"
  | "OWNER";
```

## Zod validator

```typescript
import * as z from "zod";
import type {
  GitHubUser,
  GitHubRepository,
  GitHubOrganization,
  GitHubLabel,
  GitHubMilestone,
  GitHubAuthorAssociation,
} from "../types/github-shared";

export const githubUserSchema = z.object({
  login: z.string(),
  id: z.number().int(),
  node_id: z.string(),
  avatar_url: z.string(),
  url: z.string(),
  html_url: z.string(),
  type: z.string(),
  site_admin: z.boolean(),
}) satisfies z.ZodType<GitHubUser>;

export const githubRepositorySchema = z.object({
  id: z.number().int(),
  node_id: z.string(),
  name: z.string(),
  full_name: z.string(),
  private: z.boolean(),
  owner: githubUserSchema,
  html_url: z.string(),
  description: z.string().nullable(),
  fork: z.boolean(),
  url: z.string(),
  default_branch: z.string(),
}) satisfies z.ZodType<GitHubRepository>;

export const githubOrganizationSchema = z.object({
  login: z.string(),
  id: z.number().int(),
  node_id: z.string(),
  url: z.string(),
  avatar_url: z.string(),
  description: z.string().nullable(),
}) satisfies z.ZodType<GitHubOrganization>;

export const githubLabelSchema = z.object({
  id: z.number().int(),
  node_id: z.string(),
  url: z.string(),
  name: z.string(),
  color: z.string(),
  description: z.string().nullable(),
  default: z.boolean(),
}) satisfies z.ZodType<GitHubLabel>;

export const githubMilestoneSchema = z.object({
  id: z.number().int(),
  node_id: z.string(),
  number: z.number().int(),
  title: z.string(),
  description: z.string().nullable(),
  state: z.enum(["open", "closed"]),
  open_issues: z.number().int(),
  closed_issues: z.number().int(),
  created_at: z.string(),
  updated_at: z.string(),
  closed_at: z.string().nullable(),
  due_on: z.string().nullable(),
}) satisfies z.ZodType<GitHubMilestone>;

export const githubAuthorAssociationSchema = z.enum([
  "COLLABORATOR",
  "CONTRIBUTOR",
  "FIRST_TIMER",
  "FIRST_TIME_CONTRIBUTOR",
  "MANNEQUIN",
  "MEMBER",
  "NONE",
  "OWNER",
]) satisfies z.ZodType<GitHubAuthorAssociation>;

export type {
  GitHubUser,
  GitHubRepository,
  GitHubOrganization,
  GitHubLabel,
  GitHubMilestone,
  GitHubMilestoneState,
  GitHubAuthorAssociation,
} from "../types/github-shared";
```

## Examples

```typescript
// Source: https://docs.github.com/en/webhooks/webhook-events-and-payloads#webhook-payload-object-common-properties
// Captured: 2026-05
import type {
  GitHubUser,
  GitHubRepository,
  GitHubOrganization,
  GitHubLabel,
  GitHubMilestone,
  GitHubAuthorAssociation,
} from "../types/github-shared";
import {
  githubUserOctocat,
  githubUserBot,
  githubRepositoryHelloWorld,
  githubOrganizationGitHub,
  githubLabelBug,
  githubMilestoneV1,
} from "./shared/github.examples";

export const githubUserExamples = {
  human: githubUserOctocat,
  bot: githubUserBot,
  siteAdmin: { ...githubUserOctocat, site_admin: true } satisfies GitHubUser,
} as const;

export const githubRepositoryExamples = {
  public: githubRepositoryHelloWorld,
  private: { ...githubRepositoryHelloWorld, private: true } satisfies GitHubRepository,
  fork: { ...githubRepositoryHelloWorld, fork: true } satisfies GitHubRepository,
  noDescription: {
    ...githubRepositoryHelloWorld,
    description: null,
  } satisfies GitHubRepository,
} as const;

export const githubOrganizationExamples = {
  minimal: githubOrganizationGitHub,
  noDescription: {
    ...githubOrganizationGitHub,
    description: null,
  } satisfies GitHubOrganization,
} as const;

export const githubLabelExamples = {
  bug: githubLabelBug,
  custom: {
    id: 208045947,
    node_id: "MDU6TGFiZWwyMDgwNDU5NDc=",
    url: "https://api.github.com/repos/octocat/Hello-World/labels/enhancement",
    name: "enhancement",
    color: "a2eeef",
    description: null,
    default: false,
  } satisfies GitHubLabel,
} as const;

export const githubMilestoneExamples = {
  open: githubMilestoneV1,
  closed: {
    ...githubMilestoneV1,
    state: "closed",
    closed_at: "2014-03-03T18:58:10Z",
    due_on: null,
  } satisfies GitHubMilestone,
} as const;

export const githubAuthorAssociationExamples = {
  owner: "OWNER",
  member: "MEMBER",
  collaborator: "COLLABORATOR",
  contributor: "CONTRIBUTOR",
  firstTimer: "FIRST_TIMER",
  firstTimeContributor: "FIRST_TIME_CONTRIBUTOR",
  mannequin: "MANNEQUIN",
  none: "NONE",
} as const satisfies Record<string, GitHubAuthorAssociation>;
```
