Simple Node.js script to synchronize a shared set of GitHub labels across multiple repositories using the GitHub REST API.
- Node.js 18 or higher installed.
- A GitHub personal access token with permission to manage issues/labels on your repositories.
-
Clone this repository and go into the folder:
git clone https://github.com/VialsShiny/template-labels.git cd template-labels/app -
Make sure
labels.jsoncontains the labels you want to sync. -
Set the
GITHUB_TOKENenvironment variable in your terminal session:On PowerShell (Windows):
$Env:GITHUB_TOKEN = "ghp_your_token_here"
On macOS / Linux (bash/zsh):
export GITHUB_TOKEN="ghp_your_token_here"
Run the script from the project root:
node sync-labels.mjsYou will be prompted for:
- GitHub owner (user or organization name, for example
toto) - Repos (comma‑separated list of repositories, for example
my-first-repo,another-repo)
The script will then read labels.json and create the labels on each target repository.
- Existing labels with the same name are skipped and not overwritten.
- You can run the script multiple times to ensure new labels are added to all repositories.