Skip to content

leemhoon00/github-label-copier

Repository files navigation

Github Label Copier

github-label-copier is a simple tool to copy labels from one repository, either your own or someone else's, to your own repository.

Usage

Installation

npm install github-label-copier

Import

const { createCopier } = require('github-label-copier');
// or
import { createCopier } from 'github-label-copier';

Initialization

const copier = createCopier(YOUR_GITHUB_TOKEN);

Copy Labels

copier.copyLabels({
  from: 'https://github.com/{OWNER}/{REPO}', // Source repository
  to: 'https://github.com/{OWNER}/{REPO}', // Destination repository
});

Get Labels

const labels = await copier.getLabels({
  url: 'https://github.com/freeCodeCamp/freeCodeCamp',
});
console.log(labels);

Save Labels

copier.saveLabels({
  url: 'https://github.com/Owner/Repo',
  format: 'json', // 'json' | 'yaml', Default: 'json'
});

Push Labels by Json or Yaml

# labels.yaml

- name: 'docs :books:'
  color: FFCACC
  description: docs label
- name: 'feat :sparkles:'
  color: CBFFA9
  description: add new feature
- name: 'test :white_check_mark:'
  color: DBC4F0
  description: add test
const dotenv = require('dotenv');
dotenv.config();
const { createCopier } = require('github-label-copier');

const token = process.env.GITHUB_TOKEN;

const copier = createCopier(token);

async function main() {
  copier.pushLabels({
    filename: 'labels.yaml',
    url: 'https://github.com/leemhoon00/github-label-copier',
  });
}

main();

image