github.com/yrj2011/jx-test-infra@v0.0.0-20190529031832-7a2065ee98eb/label_sync/README.md (about)

     1  # label_sync
     2  
     3  Update or migrate github labels on repos in a github org based on a YAML file
     4  
     5  ## Configuration
     6  
     7  A typical labels.yaml file looks like:
     8  
     9  ```yaml
    10  ---
    11  labels:
    12    - color: 00ff00
    13      name: lgtm
    14    - color: ff0000
    15      name: priority/P0
    16      previously:
    17      - color: 0000ff
    18        name: P0
    19    - name: dead-label
    20      color: cccccc
    21      deleteAfter: 2017-01-01T13:00:00Z
    22  ```
    23  
    24  This will ensure that:
    25  
    26  - there is a green `lgtm` label
    27  - there is a red `priority/P0` label, and previous labels should be migrated to it:
    28    - if a `P0` label exists:
    29      - if `priority/P0` does not, modify the existing `P0` label
    30      - if `priority/P0` exists, `P0` labels will be deleted, `priority/P0` labels will be added
    31  - if there is a `dead-label` label, it will be deleted after 2017-01-01T13:00:00Z
    32  
    33  ## Usage
    34  
    35  ```sh
    36  # test
    37  bazel test //label_sync/...
    38  
    39  # add or migrate labels on all repos in the kubernetes org
    40  bazel run //label_sync -- \
    41    --config $(pwd)/labels.yaml \
    42    --token /path/to/github_oauth_token \
    43    --orgs kubernetes
    44    # actually you need to pass the --confirm flag too, it will
    45    # run in dry-run mode by default so you avoid doing something
    46    # too hastily, hence why this copy-pasta isn't including it
    47  
    48  # add or migrate labels on all repos except helm in the kubernetes org
    49  bazel run //label_sync -- \
    50    --config $(pwd)/labels.yaml \
    51    --token /path/to/github_oauth_token \
    52    --orgs kubernetes \
    53    --skip kubernetes/helm
    54    # see above
    55  
    56  # add or migrate labels on the community and steering repos in the kubernetes org
    57  bazel run //label_sync -- \
    58    --config $(pwd)/labels.yaml \
    59    --token /path/to/github_oauth_token \
    60    --orgs kubernetes \
    61    --only kubernetes/community,kubernetes/steering
    62    # see above
    63  
    64  # generate docs based on labels.yaml
    65  bazel run //label_sync -- \
    66    --action docs \
    67    --config $(pwd)/label_sync/labels.yaml \
    68    --docs-template $(pwd)/label_sync/labels.md.tmpl \
    69    --docs-output $(pwd)/label_sync/labels.md
    70  ```
    71  
    72  ## Our Deployment
    73  
    74  We run this as a [`CronJob`](./cluster/label_sync_cron_job.yaml) on a kubernetes cluster managed by [test-infra oncall](https://go.k8s.io/oncall), and can also schedule it as a [`Job`](./cluster/label_sync_cron_job.yaml) for one-shot usage.
    75  
    76  These pods read [`labels.yaml`](./labels.yaml) from a ConfigMap that is updated by the [prow updateconfig plugin](/prow/plugins/updateconfig).
    77  
    78  To update the `labels.yaml` file, simply open a pull request against it.