RepoLabels is a GitHub Repository Labels command line interface which allows for easy exporting and importing of GitHub Labels.
RepoLabels.command.line.interface.Version.1.0.0.demonstration.mp4
The purpose of this project includes:
- Creating a tool which helps automate synchronisation of GitHub Labels for my personal usage and use cases.
- Serving as a practice for me to learn Python
- The usage of public APIs such as GitHub API
You can use RepoLabels to:
- Backup your GitHub labels.
- Import your GitHub labels to a different GitHub Repository.
- This avoids users having to manually reconfigure their labels when creating a new GitHub Repository or when planning to synchronise the labels of an existing repository which helps to save development time.
A brief description on how to get your copy of RepoLabels running.
We recommend using Python 3.9.5
(or later)
Python packages dependencies
Please refer to the requirements.txt
for the updated Python packages dependencies.
- Clone the RepoLabels's GitHub Repository.
- Create a
.env
file in the project root directory with the structure as shown below.
Sample .env
file (.env.sample)
# GitHub credentials
# Please refer to our documentation or GitHub documentation on how to retrieve your GitHub Personal Access Token.
# Resources:
# https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-personal-access-token
GITHUB_USERNAME=YOUR_GITHUB_USERNAME
GITHUB_PERSONAL_ACCESS_TOKEN=YOUR_GITHUB_PERSONAL_ACCESS_TOKEN
Note: Please ensure that you key in all your desired values for the respective fields in the .env
file.
-
Open your favourite terminal/command prompt in the RepoLabels's working directory.
-
Create a virtual environment in Python in the directory of where RepoLabels is located.
python -m venv <name_of_virtual_env>
-
Activate the newly created virtual environment.
<name_of_virtual_env>\Scripts\activate.bat
(Windows)<name_of_virtual_env>/bin/activate
(Linux/Mac)
-
Install the necessary Python package dependencies using the
requirements.txt
included by RepoLabelspip install -r requirements.txt
-
You can now use RepoLabels.
- To view the list of available commands:
python repolabels.py --help
- To view the list of available commands:
-
A sample list of subcommands:
-
The
sync
subcommand can be used tosync
labels from a GitHub Repository to another GitHub Repository.-
In the example below, we attempt to sync the labels from https://github.com/github/docs's GitHub Repository to a sample GitHub Repository:
python repolabels.py sync https://github.com/github/docs https://github.com/JonathanLeeWH/Sample
-
-
The
export
subcommand can be used toexport
labels from a GitHub Repository to ajson
format compatible with RepoLabels.-
In the example below, we attempt to
export
the labels from https://github.com/github/docs's GitHub Repository:python repolabels.py export https://github.com/github/docs
Note: By default, the
json
file will be exported toexported/{repo_owner}_{repo_name}_{current date and time}.json
In the example above, the
json
file exported is located inexported/github_docs_2021_06_27_19_20_50_283179.json
You can change the export destination file path using the
-d
flag followed by your desired destination file path.
-
-
The
import
subcommand can be used toimport
labels from ajson
format compatible with RepoLabels to a sample GitHub Repository.-
In the example below, we attempt to
import
the labels from thejson
file we obtained from theexport
subcommand example above to a sample repository:python repolabels.py import exported/github_docs_2021_06_27_19_20_50_283179.json https://github.com/JonathanLeeWH/Sample
-
-
The
rm-all
subcommand can be used to remove all the labels from a GitHub Repository.-
In the example below, we attempt to remove all the labels from a sample GitHub Repository:
python repolabels.py rm-all https://github.com/JonathanLeeWH/Sample
-
-
The
rate-limit
subcommand can be used to check the current rate limits for each services such as GitHub API rate limits.python repolabels.py rate-limit
-
The
update-cli
subcommand can be used to check the Latest Stable Version of RepoLabels.python repolabels.py update-cli
-
If you want to deactivate your current virtual environment, type deactivate
in your command line or terminal.
A list of the technologies and frameworks used in this project
- GitHub Actions for Continuous Integration (CI)