github-label-syncer

module
v1.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 25, 2023 License: MIT

README ยถ

github-label-syncer

โญ๏ธ sync labels between repos and org. โญ๏ธ

good first

English โ€ข ไธญๆ–‡


๐Ÿงฉ Awesome features

This document discusses the development of a Go language actions that synchronizes labels on GitHub repositories. This actions is not limited to synchronizing labels on your own repository, but can also retrieve all of the API objects of a target repository, which can then be saved to a YAML file or synchronized to your own GitHub project.

Labels are an important way of organizing and categorizing issues and pull requests on GitHub. They allow you to quickly and easily identify the status, priority, and type of each issue or pull request.

To retrieve the API objects of a GitHub project's labels, you can use the following URLs:

  • To retrieve the first page of objects: https://api.github.com/repos/<owner>/<repo>/labels?page=1&sort=name-asc
  • To retrieve all objects: https://api.github.com/repos/<owner>/<repo>/labels?per_page=100&page=1&sort=name-asc

Simply replace <owner> and <repo> with the owner and repository name, respectively. These URLs can be used to retrieve all of the labels associated with a project, which can then be synchronized or saved as needed.

github-label-syncer is a tool to sync labels between repos and org. The main features are:

  • Feel free to pick a remote repository and fetch all its labels to a local yaml, table AND json
  • Feel free to pick a remote repository and sync all of its labels to your desired project repository
  • Sync labels across repositories according to configuration
  • Create, update and delete labels
  • Dry run to preview which labels would be created, updated or deleted
  • Handle label collisions by renaming or skipping existing labels
  • Support labeling pull requests and issues

Labels denger: The labels are designed semantic and standard. We provide labels for priority, type, status etc. You can refer to the label doc to get more info.

**github actions

๐Ÿ›ซ Quick start

Note: You can get started quickly with github-label-syncer.

Work with Makefile
โฏ make help    # show help
โฏ make build   # build binary exporter and syncer
โฏ echo 'export PATH=$PATH:/path/to/_output/platforms/linux/amd64/' | tee -a ~/.zshrc;source ~/.zshrc
Work with actions

Actions provide handling of PR and issue. We used the bot ๐Ÿš€@kubbot, It can detect issues in Chinese and translate them to English, and you can interact with it using the command /comment.

Comment in an issue:

โฏ /intive
Use Github-Label-Syncer

You can set your own GITHUB_TOKEN via env or via the export GITHUB_TOKEN environment variable, or use one of the default tokens we provide, which is TOEKN for our free automated ๐Ÿค– robot

โฏ ./_output/bin/platforms/linux/amd64/exporter --help
usage: exporter [<flags>] <owner> <repo>


Flags:
      --[no-]help    Show context-sensitive help (also try --help-long and --help-man).
  -y, --[no-]yaml    Use the YAML format.
  -j, --[no-]json    Use the JSON format.
  -t, --[no-]table   Use the table format.
  -x, --[no-]xml     Use the XML format.
      --[no-]toml    Use the TOML format.
      --[no-]ini     Use the INI format.
      --[no-]csv     Use the CSV format.
  -f, --file=FILE    Export labels to file.
      --token=TOKEN  GitHub token. ($GITHUB_TOKEN)

Args:
  <owner>  Owner of the repository.
  <repo>   Repository whose wanted labels.

โฏ export GITHUB_TOKEN="ghp_****************************************0z"
โฏ exporter kubecub log --json | jq
[
  {
    "name": "major version",
    "description": "Automatically create a new major version tag after PR is merged",
    "color": "1E8DE7"
  },
  {
    "name": "merge when passing",
    "description": "Merge the PR automatically once all status checks have passed",
    "color": "FF851B"
  },
  {
    "name": "minor version",
    "description": "Automatically create a new minor version tag after PR is merged",
    "color": "6EBAF7"
  },
  {
    "name": "patch version",
    "description": "Automatically create a new patch version tag after PR is merged",
    "color": "99cef9"
  }
]

โฏ ./_output/bin/platforms/linux/amd64/exporter kubernetes kubernetes --yaml -f ./_output/tmp/kubernetes_labels.yaml
โฏ tree _output/
_output/
โ”œโ”€โ”€ bin
โ”‚   โ””โ”€โ”€ platforms
โ”‚       โ””โ”€โ”€ linux
โ”‚           โ””โ”€โ”€ amd64
โ”‚               โ”œโ”€โ”€ exporter
โ”‚               โ””โ”€โ”€ syncer
โ”œโ”€โ”€ tmp
โ”‚   โ””โ”€โ”€ kubernetes_labels.yaml
โ””โ”€โ”€ tools
    โ”œโ”€โ”€ addlicense
    โ””โ”€โ”€ go-gitlint

โฏ ./syncer --help
Work with Docker
โฏ make deploy

๐Ÿ•‹ architecture diagram

graph LR
A[Config file] -->B(github-label-syncer)
B --> C{Sync labels}
C -->|Yes| D[Create/Update labels] 
C -->|No | E[Delete labels]
D --> F[Dry run]
F --> |Yes| G[Preview]
F --> |No| H[Apply changes]
E --> I[Dry run]
I --> |Yes| J[Preview]
I --> |No| K[Apply changes]

MVC Architecture Design:

flowchart TB

A[Config file]
A --> B[github-label-syncer]
B --> C{Sync labels}
C -->|Yes|D[<font color='green'>Create/Update </font> <br>labels]
C -->|No|E[<font color='red'>Delete </font><br> labels]  
D -.-> F[<font color='blue'>Dry run</font><br>Preview]
F --> G[Apply <br>changes]
E -.-> H[<font color='blue'>Dry run</font><br>Preview]
H --> I[Apply<br> changes]
B --> J[Label <br>PRs & <br>Issues]

๐Ÿค– File Directory Description

Catalog standardization design structure:

.github-label-syncer
โ”œโ”€โ”€ CONTRIBUTING.md          # Contribution guidelines
โ”œโ”€โ”€ LICENSE                  # License information
โ”œโ”€โ”€ Makefile                 # Makefile for building and running the project
โ”œโ”€โ”€ README.md                # Project overview in English
โ”œโ”€โ”€ README_zh-CN.md          # Project overview in Chinese
โ”œโ”€โ”€ api                      # API-related files
โ”‚   โ”œโ”€โ”€ OWNERS               # API owners
โ”‚   โ””โ”€โ”€ README.md            # API documentation
โ”œโ”€โ”€ assets                   # Static assets, such as images and stylesheets
โ”‚   โ””โ”€โ”€ README.md            # Assets documentation
โ”œโ”€โ”€ build                    # Build-related files
โ”‚   โ”œโ”€โ”€ OWNERS               # Build owners
โ”‚   โ””โ”€โ”€ README.md            # Build documentation
โ”œโ”€โ”€ cmd                      # Command-line tools and entry points
โ”‚   โ”œโ”€โ”€ OWNERS               # Command owners
โ”‚   โ””โ”€โ”€ README.md            # Command documentation
โ”œโ”€โ”€ configs                  # Configuration files
โ”‚   โ”œโ”€โ”€ OWNERS               # Configuration owners
โ”‚   โ”œโ”€โ”€ README.md            # Configuration documentation
โ”‚   โ””โ”€โ”€ config.yaml          # Main configuration file
โ”œโ”€โ”€ deploy                   # Deployment-related files
โ”‚   โ”œโ”€โ”€ OWNERS               # Deployment owners
โ”‚   โ””โ”€โ”€ README.md            # Deployment documentation
โ”œโ”€โ”€ docs                     # Project documentation
โ”‚   โ”œโ”€โ”€ OWNERS               # Documentation owners
โ”‚   โ””โ”€โ”€ README.md            # Documentation index
โ”œโ”€โ”€ examples                 # Example code and usage
โ”‚   โ”œโ”€โ”€ OWNERS               # Example owners
โ”‚   โ””โ”€โ”€ README.md            # Example documentation
โ”œโ”€โ”€ init                     # Initialization files
โ”‚   โ”œโ”€โ”€ OWNERS               # Initialization owners
โ”‚   โ””โ”€โ”€ README.md            # Initialization documentation
โ”œโ”€โ”€ internal                 # Internal application code
โ”‚   โ”œโ”€โ”€ OWNERS               # Internal code owners
โ”‚   โ”œโ”€โ”€ README.md            # Internal code documentation
โ”‚   โ”œโ”€โ”€ app                  # Application logic
โ”‚   โ”œโ”€โ”€ pkg                  # Internal packages
โ”‚   โ””โ”€โ”€ utils                # Utility functions and helpers
โ”œโ”€โ”€ pkg                      # Public packages and libraries
โ”‚   โ”œโ”€โ”€ OWNERS               # Package owners
โ”‚   โ”œโ”€โ”€ README.md            # Package documentation
โ”‚   โ”œโ”€โ”€ common               # Common utilities and helpers
โ”‚   โ”œโ”€โ”€ log                  # Log utilities
โ”‚   โ”œโ”€โ”€ tools                # Tooling and scripts
โ”‚   โ”œโ”€โ”€ utils                # General utility functions
โ”‚   โ””โ”€โ”€ version              # Version information
โ”œโ”€โ”€ scripts                  # Scripts for development and automation
โ”‚   โ”œโ”€โ”€ LICENSE_TEMPLATES    # License templates
โ”‚   โ”œโ”€โ”€ OWNERS               # Script owners
โ”‚   โ”œโ”€โ”€ README.md            # Script documentation
โ”‚   โ”œโ”€โ”€ githooks             # Git hooks for development
โ”‚   โ””โ”€โ”€ make-rules           # Makefile rules and scripts
โ”œโ”€โ”€ test                     # Test files and test-related utilities
โ”‚   โ”œโ”€โ”€ OWNERS               # Test owners
โ”‚   โ””โ”€โ”€ README.md            # Test documentation
โ”œโ”€โ”€ third_party              # Third-party dependencies and libraries
โ”‚   โ””โ”€โ”€ README.md            # Third-party documentation
โ”œโ”€โ”€ tools                    # Tooling and utilities for development
โ”‚   โ””โ”€โ”€ README.md            # Tool documentation
โ””โ”€โ”€ web                      # Web-related files, such as HTML and CSS
    โ”œโ”€โ”€ OWNERS               # Web owners
    โ””โ”€โ”€ README.md            # Web documentation

๐Ÿ—“๏ธ community meeting

We welcome everyone to join us and contribute to github-label-syncer, whether you are new to open source or professional. We are committed to promoting an open source culture, so we offer community members neighborhood prizes and reward money in recognition of their contributions. We believe that by working together, we can build a strong community and make valuable open source tools and resources available to more people. So if you are interested in github-label-syncer, please join our community and start contributing your ideas and skills!

We take notes of each biweekly meeting in GitHub discussions, and our minutes are written in Google Docs.

github-label-syncer maintains a public roadmap. It gives a a high-level view of the main priorities for the project, the maturity of different features and projects, and how to influence the project direction.

๐Ÿคผโ€ Contributing & Development

kubecub Our goal is to build a top-level open source community. We have a set of standards, in the Community repository.

If you'd like to contribute to this github-label-syncer repository, please read our contributor documentation.

Before you start, please make sure your changes are in demand. The best for that is to create a new discussion OR Slack Communication, or if you find an issue, report it first.

๐Ÿšจ License

Kubecub is licensed under the MIT License, Version 2.0. See LICENSE for the full license text.

FOSSA Status

๐Ÿ”ฎ Thanks to our contributors!

Directories ยถ

Path Synopsis
cmd
internal
utils/interrupt
Package interrupt deal with signals.
Package interrupt deal with signals.
utils/term
Package term provides structures and helper functions to work with terminal (state, sizes).
Package term provides structures and helper functions to work with terminal (state, sizes).
pkg
log

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL