An open API service indexing awesome lists of open source software.

https://github.com/karthikudyawar/github-label-sync-tool

Tool that sync labels from CSV to GitHub repositories via CLI.
https://github.com/karthikudyawar/github-label-sync-tool

automation bash cli-tool conventionalcommits csv developer-tools github-api github-label-manager github-labels label-management label-sync open-source shell-script shellcheck

Last synced: 3 months ago
JSON representation

Tool that sync labels from CSV to GitHub repositories via CLI.

Awesome Lists containing this project

README

          

πŸš€ GitHub Label Sync Tool


Sync Smarter. Label Better.



GitHub stars


License

ShellCheck
PRs Welcome


GitHub Label Sync Tool Logo

---

A shell script to **sync GitHub issue labels** from a CSV file to a repository using the GitHub API.
Easily validate, create, update, and optionally delete labels to keep your GitHub repositories clean and consistent.

---

## πŸ“œ Table of Contents

- [πŸ“œ Table of Contents](#-table-of-contents)
- [πŸ›  Features](#-features)
- [πŸ“¦ Installation](#-installation)
- [πŸš€ Usage](#-usage)
- [Flags](#flags)
- [πŸ§ͺ CSV Format](#-csv-format)
- [Constraints](#constraints)
- [πŸ” Authentication](#-authentication)
- [πŸ“ˆ Output Summary](#-output-summary)
- [πŸ§‘β€πŸ’» Contributing](#-contributing)
- [πŸ§ͺ Before submitting a PR](#-before-submitting-a-pr)
- [πŸ“„ License](#-license)

---

## πŸ›  Features

- βœ… Validates label CSV structure and field formats
- πŸ”„ Creates or updates GitHub labels
- 🧹 Optionally deletes existing labels not in CSV
- πŸ” Uses GitHub Personal Access Token (PAT) for authentication
- πŸ’¬ Provides detailed feedback during syncing
- πŸ’‘ Simple, dependency-free Bash script

---

## πŸ“¦ Installation

```bash
git clone https://github.com/KarthikUdyawar/GitHub-Label-Sync-Tool.git
cd GitHub-Label-Sync-Tool
chmod +x github_label_sync.sh
```

---

## πŸš€ Usage

```bash
./github_label_sync.sh -f labels.csv -r user/repo [-d]
```

### Flags

| Flag | Description |
|------|-------------|
| `-f` | Path to the CSV file (default: `labels.csv`) |
| `-r` | Target GitHub repository in format `user/repo` |
| `-d` | Delete existing labels not in CSV (optional) |
| `-h` | Show help message |

---

## πŸ§ͺ CSV Format

The input file must have a header and exactly 3 columns per row:

```csv
name,color,description
bug,f29513,Something isn't working
enhancement,84b6eb,New feature or request
```

### Constraints

- `name` must not be empty
- `color` must be a valid hex (e.g., `f29513`)
- `description` must not exceed 100 characters

---

## πŸ” Authentication

The script uses the `GITHUB_TOKEN` environment variable or prompts for it securely:

```bash
export GITHUB_TOKEN=ghp_XXXXXXXXXXXXXXXXXXXXXXXXXXXX
```

Ensure the token has **repo** scope.

---

## πŸ“ˆ Output Summary

At the end of the script, you’ll see a summary like:

```
πŸŽ‰ Sync complete!
βœ… Created: 3
πŸ”„ Updated: 4
❌ Failed: 1
```

## πŸ§‘β€πŸ’» Contributing

Contributions are welcome! Whether it's a bug fix, feature suggestion, improvement, or documentation updateβ€”feel free to open an issue or submit a pull request.

To contribute:

```bash
# 1. Fork the repository
git clone https://github.com/KarthikUdyawar/GitHub-Label-Sync-Tool.git
cd GitHub-Label-Sync-Tool

# 2. Create a new branch for your feature or fix
git checkout -b my-feature-branch

# 3. Make your changes and commit
# (use clear and descriptive commit messages)
git add .
git commit -m "✨ Add new feature XYZ"

# 4. Push to your fork and open a pull request
git push origin my-feature-branch
```

### πŸ§ͺ Before submitting a PR

- βœ… Ensure your changes are tested and working.
- 🧹 Lint your shell script using [ShellCheck](https://www.shellcheck.net/):

```bash
docker run --rm -v "$PWD:/mnt" koalaman/shellcheck:stable ./github_label_sync.sh
```

- πŸ“œ Update the README or docs if your changes affect usage or behavior.
- πŸ“Œ Reference the issue number in your PR if it's related to an open issue.
- πŸ› οΈ Use [Conventional Commits](https://www.conventionalcommits.org/) for commit messages.
- πŸ” Check [open issues](https://github.com/KarthikUdyawar/GitHub-Label-Sync-Tool/issues) for inspiration or existing tasks.

---

## πŸ“„ License

Distributed under the MIT License. See `LICENSE` for more information.