LinuxCommandLibrary

github-label-sync

Synchronize GitHub repository labels

TLDR

Synchronize labels using a local labels.json file

$ github-label-sync --access-token [token] [repository_name]
copy

Synchronize labels using a specific labels JSON file
$ github-label-sync --access-token [token] --labels [url|path/to/json_file] [repository_name]
copy

Perform a dry run instead of actually synchronizing labels
$ github-label-sync --access-token [token] --dry-run [repository_name]
copy

Keep labels that aren't in labels.json
$ github-label-sync --access-token [token] --allow-added-labels [repository_name]
copy

Synchronize using the GITHUB_ACCESS_TOKEN environment variable
$ github-label-sync [repository_name]
copy

SYNOPSIS

github-label-sync [options]

PARAMETERS

--version
    Show version.

--help
    Show help message.

--github-token
    GitHub API token (defaults to GITHUB_TOKEN env var).

--github-api
    GitHub API base URL (defaults to https://api.github.com).

--dry-run
    Perform a dry-run without making any changes.

--labels-url
    URL pointing to a JSON or YAML file containing the labels configuration (alternative to a local file).

--only-manage-labels
    Only manage specified labels (comma-separated).

--skip-labels
    Skip specified labels from synchronization (comma-separated).

--allow-deletes
    Allow the tool to delete labels that are not present in the configuration.

--repo
    Target repository (org/repo) - can be specified multiple times.

--repo-file
    File containing a list of repositories (one per line).

--no-color
    Disable colored output.

--log-level
    Set log level (debug, info, warn, error, fatal) - defaults to info.

DESCRIPTION

github-label-sync is a command-line tool designed to synchronize labels across multiple GitHub repositories.
It allows you to define a centralized label configuration (typically in a YAML file) and apply it consistently to all your target repositories. This eliminates the need for manual label management and ensures uniformity across your projects.
The tool supports adding, updating, and deleting labels to match the configuration. It provides various options for filtering repositories, handling dry-runs, and customizing the synchronization process. It is useful for organizations managing many GitHub repositories and want to ensure all of them have a standard set of labels. It leverages the GitHub API to perform label management tasks and provides clear output detailing the changes made to each repository.

CAVEATS

Requires a valid GitHub API token with sufficient permissions to manage labels in the target repositories. Rate limiting by the GitHub API may impact performance, especially with a large number of repositories. Be careful with `--allow-deletes`, as it can permanently remove labels.

CONFIGURATION FILE FORMAT

The configuration file is typically a YAML file that defines the desired labels. Each label entry should include properties like name, color, and description.

ERROR HANDLING

The command provides error messages and logging information to help troubleshoot issues during synchronization.

HISTORY

github-label-sync has evolved to address the need for centralized label management in GitHub organizations. The initial versions likely focused on basic synchronization functionality. Over time, features like dry-run mode, repository filtering, and support for remote label configurations were added to enhance usability and flexibility.

Copied to clipboard