Copy GitHub labels
Easily copy GitHub labels from one repository to another. Uses GitHub API for Node.js.
If you want to copy GitHub labels from your command-line instead of from a script, check out copy-github-labels-cli.
Installation
$ npm install copy-github-labels
Example
// Instantiatevar copyGitHubLabels = ; // Optionally use credentialscopyGitHubLabels; // Copy labels from one repository to anothercopyGitHubLabels;
Options
By default, copyGitHubLabels
is configured to use GitHub, but you can optionally pass in an options
object during instantiation:
// Define custom optionsvar options = version: '3.0.0' debug: true protocol: 'https' host: 'github.my-GHE-enabled-company.com' pathPrefix: '/api/v3' // for some GHEs timeout: 5000 headers: 'user-agent': 'My-Cool-GitHub-App' // GitHub is happy with a unique user agent ); // Instantiate with custom optionsvar copyGitHubLabels = options;
All node-github API options are supported.
API
Once you have instantiated copyGitHubLabels
, you can use the following methods:
authenticate(credentials)
Specify credentials to use when connecting to GitHub:
// Use basic authcopyGitHubLabels; // Or use oauthcopyGitHubLabels; // Or use oauth key/ secretcopyGitHubLabels; // Or use a tokencopyGitHubLabels;
copy(source, destination[, callback])
Copy labels from one repository to another:
// A repo can be a stringvar source = 'github-username/repo-name'; // Or an objectvar destination = owner: 'github-username' repo: 'repo-name'; // Copy labels from one repository to anothercopyGitHubLabels;
Dry runs
There is a special option called dryRun
to perform a test run without actually copying the labels.
This is convenient if you want to check if the correct labels are coming in before performing the actual copy:
// Define custom optionsvar options = // Dry run is a special option that allows us to perform // a test run without actually copying the labels. dryRun: true; // Instantiate with custom optionsvar copyGitHubLabels = options; // Define source and destinationvar source = 'jvandemo/copy-github-labels';var destination = 'your-username/your-repo'; // Copy labels from one repository to another// The callback is called for every label but no actual// copy operation is performed, so the destination repository is not updated.copyGitHubLabels;
Change log
v2.0.0
- replaced deprecated Github package with Octokit rest.js (credits to Edric Chan)
- added support to copy label description (credits to Edric Chan)
v1.3.1
- removed console.log statement
v1.3.0
- added support for more than 30 labels
- reformatted source code
- updated documentation
v1.2.1
- fix documentation
v1.2.0
- added documentation
- added additional unit tests
v1.1.0
- added support for obsolete callback
v1.0.0
- added authentication support
- added documentation
- packaged as npm module