# it-bens/container-registry-sync-action architecture

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

- Interactive diagram: https://gitdiagram.com/it-bens/container-registry-sync-action
- Repository: https://github.com/it-bens/container-registry-sync-action

## Overview

##### Project Type & Purpose
- This is a GitHub Action for container registry synchronization. Its main goal is to automate the copying of Docker image tags between registries, and it supports logins through both Docker and regclient methods.
- The README outlines the usage with YAML examples to help users integrate the action within CI/CD pipelines, while the file structure confirms a modular architecture (with tests, source modules, workflows, etc.).

##### File Structure for Key Components
- Top-Level Files: Files like action.yml, README.md, package.json, and tsconfig.json define the project configuration, build settings, and GitHub Action metadata.
- Source Code (src/): Contains the implementation split across multiple components:
- Action.ts and Inputs.ts: Define the action’s entry points and expected inputs.
- Login/ folder: Likely manages repository login logic for both source and target registries.
- Utils/ folder: Provides helper functions including GitHub Action integrations (exec, logging) and components for interacting with regclient.
- Distribution (dist/): Houses the compiled code which is ultimately used when the action runs.
- CI/CD Configuration (.github/workflows): Configurations for linting, CodeQL, release checks, etc.
- Tests: Organized test folders (__tests__) for validating all modules.
- Scripts and Build Configurations: rollup.config.ts and tsconfig files indicate how the code is bundled and compiled.

##### Main Components
a. GitHub Action Workflow Environment:
- Components like the CI/CD pipeline (triggered via GitHub workflows), representing environments like the runner and the action steps.
b. Core Action Components:
- Action Entrypoint: Represented by action.yml and src/Action.ts, which serves as the main controller for the GitHub Action.
- Input Processing: The Inputs.ts module that handles and validates configuration as provided by the user.
- Business Logic Modules:
- Login Module (src/Login): Manages authentication for both source and target registries.
- Utility Modules (src/Utils): Handling logging, command execution (e.g., regclient invocation), tag filtering, and image synchronization logic.
c. External Dependencies:
- regclient/regctl: The external CLI tool required to perform image copy operations between registries.
d. CI/CD & Testing Components:
- Tests & Fixtures: Represented to show the robust testing framework implemented to ensure reliability.

##### Relationships & Data Flow
- The workflow starts when a user triggers the GitHub Action. The action reads inputs from the workflow YAML configuration.
- The Inputs module validates configurations and passes them to the core action component.
- The Login module is used to authenticate with the container registries based on the provided credentials.
- The action then delegates to the utility modules to fetch available image tags using regclient, apply glob-based filtering, and trigger the synchronization (copying images) between registries.
- External dependencies like regclient are invoked as subprocesses (or via a library wrapper) with appropriate parameters.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "GitHub Environment"
        W["GitHub Workflow Runner"]:::ci
        C["CI/CD Pipeline & Testing"]:::ci
    end

    subgraph "Action Core"
        A["Action Entrypoint (action.yml & src/Action.ts)"]:::core
        I["Input Processor (src/Inputs.ts)"]:::core
        L["Authentication Module (Login)"]:::core
        U["Utility Modules (Utils)"]:::core
    end

    subgraph "External Dependency"
        R["External CLI: regclient"]:::external
    end

    W -->|"triggers"| A
    A -->|"processes"| I
    A -->|"authenticatesWith"| L
    A -->|"executesVia"| U
    U -->|"invokes"| R

    C -->|"testsAndLints"| A
    C -->|"tests"| I
    C -->|"tests"| L
    C -->|"tests"| U

    classDef ci fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef core fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef external fill:#f8d7da,stroke:#721c24,stroke-width:2px;

    click W "https://github.com/it-bens/container-registry-sync-action/tree/main/.github/workflows"
    click A "https://github.com/it-bens/container-registry-sync-action/blob/main/action.yml"
    click A "https://github.com/it-bens/container-registry-sync-action/blob/main/src/Action.ts"
    click I "https://github.com/it-bens/container-registry-sync-action/blob/main/src/Inputs.ts"
    click L "https://github.com/it-bens/container-registry-sync-action/tree/main/src/Login"
    click L "https://github.com/it-bens/container-registry-sync-action/blob/main/src/Login/Action.ts"
    click L "https://github.com/it-bens/container-registry-sync-action/blob/main/src/Login/Service/RegClientCredentialsBuilder.ts"
    click U "https://github.com/it-bens/container-registry-sync-action/tree/main/src/Utils"
    click U "https://github.com/it-bens/container-registry-sync-action/tree/main/src/Utils/GitHubAction"
    click U "https://github.com/it-bens/container-registry-sync-action/blob/main/src/Utils/Logger.ts"
    click U "https://github.com/it-bens/container-registry-sync-action/blob/main/src/Utils/RegClient.ts"
    click U "https://github.com/it-bens/container-registry-sync-action/blob/main/src/Utils/RegClientConcurrencyLimiter.ts"
    click U "https://github.com/it-bens/container-registry-sync-action/blob/main/src/Utils/RegClientCredentials.ts"
    click U "https://github.com/it-bens/container-registry-sync-action/blob/main/src/Utils/TagFilter.ts"
    click U "https://github.com/it-bens/container-registry-sync-action/blob/main/src/Utils/TagSorter.ts"
    click C "https://github.com/it-bens/container-registry-sync-action/tree/main/__tests__"
    click C "https://github.com/it-bens/container-registry-sync-action/tree/main/.github/workflows"
```
