# actions/checkout architecture

> Architecture diagram of the GitHub repository actions/checkout, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/actions/checkout
- Repository: https://github.com/actions/checkout

## Overview

Checkout is a GitHub Action that reads workflow inputs, validates checkout settings, obtains repository content, and places the requested revision in the workspace. Its main source-provider orchestrates repository preparation, Git fetch/checkout, and API archive fallback; credentials and post-job cleanup are separate concerns. The README documents sparse checkout, partial clone, LFS, submodules, and credential persistence. Some feature implementations were not excerpted, so links rely on the source index or README where supported.

Main entry points: [`src/git-source-provider.ts`](https://github.com/actions/checkout/blob/main/src/git-source-provider.ts) (Source orchestration), [`src/git-command-manager.ts`](https://github.com/actions/checkout/blob/main/src/git-command-manager.ts) (Git command manager), [`src/main.ts`](https://github.com/actions/checkout/blob/main/src/main.ts) (Action lifecycle), [`src/input-helper.ts`](https://github.com/actions/checkout/blob/main/src/input-helper.ts) (Input parsing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Action entry"]
  node_main["Action lifecycle<br/>[main.ts]"]
  node_inputs["Input parsing<br/>[input-helper.ts]"]
  node_settings["Checkout settings"]
end

subgraph group_checkout["Checkout workflow"]
  node_provider["Source orchestration"]
  node_directory["Workspace preparation"]
  node_api["Archive and repository API"]
end

subgraph group_git["Git operations"]
  node_refs["Ref resolution<br/>[ref-helper.ts]"]
  node_gitcmd["Git command manager"]
  node_gitversion["Git version<br/>[git-version.ts]"]
  node_url["Repository URLs<br/>[url-helper.ts]"]
  node_fs["Filesystem helpers<br/>[fs-helper.ts]"]
  node_retry["Retry handling<br/>[retry-helper.ts]"]
end

subgraph group_security["Credentials and safety"]
  node_auth["Git authentication<br/>[git-auth-helper.ts]"]
  node_unsafe["Unsafe PR guard"]
  node_workflow["Workflow context"]
  node_state["Post-job state<br/>[state-helper.ts]"]
end

node_runner(("Workflow runner"))
node_remote(("GitHub repository"))

node_runner -->|"invokes"| node_main
node_main -->|"reads inputs"| node_inputs
node_inputs -->|"builds settings"| node_settings
node_inputs -->|"checks checkout"| node_unsafe
node_inputs -->|"reads context"| node_workflow
node_main -->|"requests checkout"| node_provider
node_main -->|"checks post state"| node_state
node_provider -->|"uses settings"| node_settings
node_provider -->|"prepares workspace"| node_directory
node_provider -->|"runs Git operations"| node_gitcmd
node_provider -->|"configures credentials"| node_auth
node_provider -->|"requests API fallback"| node_api
node_provider -->|"resolves refs"| node_refs
node_provider -->|"checks workspace"| node_fs
node_provider -->|"saves cleanup state"| node_state
node_api -->|"requests repository data"| node_remote
node_api -->|"retries downloads"| node_retry
node_api -->|"resolves API URL"| node_url
node_gitcmd -->|"detects version"| node_gitversion
node_gitcmd -->|"uses ref helpers"| node_refs
node_gitcmd -->|"uses filesystem helpers"| node_fs
node_auth -->|"configures Git"| node_gitcmd
node_auth -->|"saves credential paths"| node_state
node_directory -->|"prepares existing repo"| node_gitcmd
node_main -->|"cleans up post-job"| node_provider
node_provider -->|"fetches and checks out"| node_gitcmd
node_provider -.->|"downloads repository"| node_remote
node_gitcmd -->|"retries Git commands"| node_retry

click node_main "https://github.com/actions/checkout/blob/main/src/main.ts"
click node_inputs "https://github.com/actions/checkout/blob/main/src/input-helper.ts"
click node_settings "https://github.com/actions/checkout/blob/main/src/git-source-settings.ts"
click node_provider "https://github.com/actions/checkout/blob/main/src/git-source-provider.ts"
click node_directory "https://github.com/actions/checkout/blob/main/src/git-directory-helper.ts"
click node_api "https://github.com/actions/checkout/blob/main/src/github-api-helper.ts"
click node_refs "https://github.com/actions/checkout/blob/main/src/ref-helper.ts"
click node_gitcmd "https://github.com/actions/checkout/blob/main/src/git-command-manager.ts"
click node_gitversion "https://github.com/actions/checkout/blob/main/src/git-version.ts"
click node_url "https://github.com/actions/checkout/blob/main/src/url-helper.ts"
click node_fs "https://github.com/actions/checkout/blob/main/src/fs-helper.ts"
click node_auth "https://github.com/actions/checkout/blob/main/src/git-auth-helper.ts"
click node_unsafe "https://github.com/actions/checkout/blob/main/src/unsafe-pr-checkout-helper.ts"
click node_workflow "https://github.com/actions/checkout/blob/main/src/workflow-context-helper.ts"
click node_state "https://github.com/actions/checkout/blob/main/src/state-helper.ts"
click node_retry "https://github.com/actions/checkout/blob/main/src/retry-helper.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main,node_inputs,node_settings toneBlue
class node_provider,node_directory,node_api toneAmber
class node_refs,node_gitcmd,node_gitversion,node_url,node_fs,node_retry toneMint
class node_auth,node_unsafe,node_workflow,node_state toneRose
class node_runner,node_remote toneIndigo
```

## Components

### Action entry

- [Action lifecycle](https://github.com/actions/checkout/blob/main/src/main.ts): `src/main.ts`
- [Input parsing](https://github.com/actions/checkout/blob/main/src/input-helper.ts): `src/input-helper.ts`
- [Checkout settings](https://github.com/actions/checkout/blob/main/src/git-source-settings.ts): `src/git-source-settings.ts`

### Checkout workflow

- [Source orchestration](https://github.com/actions/checkout/blob/main/src/git-source-provider.ts): `src/git-source-provider.ts`
- [Workspace preparation](https://github.com/actions/checkout/blob/main/src/git-directory-helper.ts): `src/git-directory-helper.ts`
- [Archive and repository API](https://github.com/actions/checkout/blob/main/src/github-api-helper.ts): `src/github-api-helper.ts`

### Git operations

- [Ref resolution](https://github.com/actions/checkout/blob/main/src/ref-helper.ts): `src/ref-helper.ts`
- [Git command manager](https://github.com/actions/checkout/blob/main/src/git-command-manager.ts): `src/git-command-manager.ts`
- [Git version](https://github.com/actions/checkout/blob/main/src/git-version.ts): `src/git-version.ts`
- [Repository URLs](https://github.com/actions/checkout/blob/main/src/url-helper.ts): `src/url-helper.ts`
- [Filesystem helpers](https://github.com/actions/checkout/blob/main/src/fs-helper.ts): `src/fs-helper.ts`
- [Retry handling](https://github.com/actions/checkout/blob/main/src/retry-helper.ts): `src/retry-helper.ts`

### Credentials and safety

- [Git authentication](https://github.com/actions/checkout/blob/main/src/git-auth-helper.ts): `src/git-auth-helper.ts`
- [Unsafe PR guard](https://github.com/actions/checkout/blob/main/src/unsafe-pr-checkout-helper.ts): `src/unsafe-pr-checkout-helper.ts`
- [Workflow context](https://github.com/actions/checkout/blob/main/src/workflow-context-helper.ts): `src/workflow-context-helper.ts`
- [Post-job state](https://github.com/actions/checkout/blob/main/src/state-helper.ts): `src/state-helper.ts`

### Other components

- **Workflow runner**
- **GitHub repository**

## Connections

- Workflow runner → Action lifecycle: invokes (evidence: `README.md`)
- Action lifecycle → Input parsing: reads inputs (evidence: `src/main.ts`)
- Input parsing → Checkout settings: builds settings (evidence: `src/input-helper.ts`)
- Input parsing → Unsafe PR guard: checks checkout (evidence: `src/input-helper.ts`)
- Input parsing → Workflow context: reads context (evidence: `src/input-helper.ts`)
- Action lifecycle → Source orchestration: requests checkout (evidence: `src/main.ts`)
- Action lifecycle → Post-job state: checks post state (evidence: `src/main.ts`)
- Source orchestration → Checkout settings: uses settings (evidence: `src/git-source-provider.ts`)
- Source orchestration → Workspace preparation: prepares workspace (evidence: `src/git-source-provider.ts`)
- Source orchestration → Git command manager: runs Git operations (evidence: `src/git-source-provider.ts`)
- Source orchestration → Git authentication: configures credentials (evidence: `src/git-source-provider.ts`)
- Source orchestration → Archive and repository API: requests API fallback (evidence: `src/git-source-provider.ts`)
- Source orchestration → Ref resolution: resolves refs (evidence: `src/git-source-provider.ts`)
- Source orchestration → Filesystem helpers: checks workspace (evidence: `src/git-source-provider.ts`)
- Source orchestration → Post-job state: saves cleanup state (evidence: `src/git-source-provider.ts`)
- Archive and repository API → GitHub repository: requests repository data (evidence: `src/github-api-helper.ts`)
- Archive and repository API → Retry handling: retries downloads (evidence: `src/github-api-helper.ts`)
- Archive and repository API → Repository URLs: resolves API URL (evidence: `src/github-api-helper.ts`)
- Git command manager → Git version: detects version (evidence: `src/git-command-manager.ts`)
- Git command manager → Ref resolution: uses ref helpers (evidence: `src/git-command-manager.ts`)
- Git command manager → Filesystem helpers: uses filesystem helpers (evidence: `src/git-command-manager.ts`)
- Git authentication → Git command manager: configures Git (evidence: `src/git-auth-helper.ts`)
- Git authentication → Post-job state: saves credential paths (evidence: `src/git-auth-helper.ts`)
- Workspace preparation → Git command manager: prepares existing repo (evidence: `src/git-directory-helper.ts`)
- Action lifecycle → Source orchestration: cleans up post-job (evidence: `src/main.ts`)
- Source orchestration → Git command manager: fetches and checks out (evidence: `README.md`)
- Source orchestration → GitHub repository: downloads repository
- Git command manager → Retry handling: retries Git commands (evidence: `src/git-command-manager.ts`)
