GitHub tools to synchronize milestones or labels across all organization/user repositories.
-
Node.JS v8.x LTS or above.
The suggested way to install node.js is install Node Version Manager. Follow this instruction to install.
-
GitHub credentials. You can use your username and password, or generate access tokens from GitHub Settings - Developer Settings - Personal access tokens.
Install from npm registry.
npm install github-sync-repos -g
To upgrade, you can run the above command again.
To find command help, type gsr -h
:
$ gsr -h
Usage: gsr [options] <command> [command-options]
Commands:
gsr labels <command> List/add/delete labels of organization or user.
[aliases: lb]
gsr milestones <command> List/add/delete milestones of a repository.
[aliases: ms]
gsr repositories <command> List repositories of organization or user.
[aliases: repos, repo, rp]
GitHub:
--organization Github organization name.
--template-repo Github template repository name.
--username, -u Github account username. Required if API token is empty.
--password, -p Github account password. Required if API token is empty.
--token Github API token. Required if username is empty.
Options:
--version Show version number [boolean]
--config Path to JSON config file
--format Response format. Available values are: plain, json.
[default: "plain"]
--verbose, -v Show more processing details. [boolean] [default: false]
-h, --help Show help [boolean]
For each command, you can type gsr <command> -h
to get more detail help.
There are several ways to provide command line options. The priority of finding options are (from top to low):
- Command line options,
- Environment variables on command line,
- Environment variables defined in .env file,
- Config json file,
- Default option value shown in
gsr -h
.
You can use gsr --token <my-api-token> <command>
to specify API token in command line.
Use GSR_
to prefix your capitalized option name as environment variable name. For example:
$ GSR_TOKEN=<my-api-token> GSR_ORGANIZATION=<my-org-name> GSR_TEMPLATE_REPO=<tpl> gsr ls-repos
If you are using Windows, you will need cross-env. Install with command npm install --g cross-env
then you can prefix the above command with cross-env
. For example:
$ cross-env GSR_TOKEN=<my-api-token> GSR_ORGANIZATION=<my-org-name> GSR_TEMPLATE_REPO=<tpl> gsr ls-repos
You can put GSR_*
environment variables into a .env
file. Please note, the .env
has to be in same folder where you issue gsr
command.
For example, create a .env
file with this content and put into folder where you usually run your gsr
command:
GSR_ORGANIZATION=<my-org>
GSR_TEMPLATE_REPO=<my-tpl-repo>
GSR_TOKEN=<my-api-token>
You can create a config json file with key/value of option name/value. For example, create a ~/.config/gsr.json
with this content:
{
"organization": "<my-org>",
"template-repo": "<my-tpl-repo>",
"token": "<my-api-token>"
}
Then use this command to use the config file:
$ gsr --config ~/.config/gsr.json [command]