# tailscale/github-action architecture

> Architecture diagram of the GitHub repository tailscale/github-action, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tailscale/github-action
- Repository: https://github.com/tailscale/github-action

## Overview

##### Main Components
- GitHub Workflow Runner Environment:
- Environment that gets triggered on a GitHub Action run.
- That this runner executes the workflow (e.g., .github/workflows/tailscale.yml).
- Tailscale GitHub Action Module:
- Action component (action.yml file) that encapsulates the integration with Tailscale.
- Configuration inputs such as oauth-client-id, oauth-secret, authkey, tags, statedir, and version.
- Tailscale Authentication & Connection:
- Two potential flows:
▪ OAuth Client Flow: Uses OAuth client credentials to connect the ephemeral node.
▪ Tailnet Lock Flow: Uses a pre-signed auth key along with a state directory for storing client state data.
- Tailscale Coordination/Control Plane:
- An external Tailscale network/service component where the ephemeral nodes are registered, marked preapproved, and later cleaned up.
- That this external system handles ACL tags and device approvals.

##### Relationships and Interactions
- The GitHub Workflow runner kicks off a workflow (via the YAML file in .github/workflows) that references the Tailscale GitHub Action.
- The Tailscale GitHub Action receives input parameters (via action.yml) and then initiates a connection to the Tailscale control server.
- Depending on the inputs, the connection flow diverges into either the OAuth credentials mode or Tailnet Lock mode.
- After authentication, the Tailscale client sets up an ephemeral node that is integrated into the tailnet, with subsequent workflow steps enabled to access internal nodes as needed.

##### Architectural Patterns and Design Principles
- Modularity: The action is designed as a self-contained module that can be easily plugged into different GitHub workflows.
- Extensibility: Note that version selection (specific version vs. latest) and support for both connection flows (OAuth vs. auth key) allow for adaptable use cases per workflow.

##### Technologies and Frameworks
- GitHub Actions: Driving the workflows via the .github/workflows and action.yml files.
- Tailscale: The external networking tool that provides secure connectivity between nodes.
- OAuth and Tailnet Lock: Authentication mechanisms are key to the action’s configuration.

## Diagram (Mermaid)

```mermaid
graph TD
    subgraph "GitHub Environment"
        A["Workflow Trigger (.github/workflows/tailscale.yml)"]:::github
        B["Tailscale Action Module (action.yml)\n(inputs: oauth-client-id, oauth-secret, authkey, tags, statedir, version)"]:::github
    end

    A -->|"triggers"| B
    B --> C["Select Authentication\nMethod"]
    C -->|"OAuth"| D["OAuth Client Flow\n(uses oauth-client-id/secret)"]:::auth
    C -->|"TailnetLock"| E["Tailnet Lock Flow\n(uses authkey & statedir)"]:::auth
    D --> F["Setup Ephemeral Node"]:::auth
    E --> F
    F --> G["Tailscale Control Plane / Tailnet\n(node registration, ACL, cleanup)"]:::external

    click A "https://github.com/tailscale/github-action/blob/main/.github/workflows/tailscale.yml"
    click B "https://github.com/tailscale/github-action/blob/main/action.yml"

    classDef github fill:#add8e6,stroke:#333,stroke-width:2px;
    classDef auth fill:#d5f5e3,stroke:#333,stroke-width:2px;
    classDef external fill:#f9e79f,stroke:#333,stroke-width:2px;
```
