k8s.io/test-infra@v0.0.0-20240520184403-27c6b4c223d8/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  go test ./label_sync
    38  
    39  # add or migrate labels on all repos in the kubernetes org
    40  go run ./label_sync \
    41    --config $(pwd)/label_sync/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  go run ./label_sync \
    50    --config $(pwd)/label_sync/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  go run ./label_sync \
    58    --config $(pwd)/label_sync/labels.yaml \
    59    --token /path/to/github_oauth_token \
    60    --only kubernetes/community,kubernetes/steering
    61    # see above
    62  
    63  # generate docs and a css file contains labels styling based on labels.yaml
    64  go run ./label_sync \
    65    --action docs \
    66    --config $(pwd)/label_sync/labels.yaml \
    67    --docs-template $(pwd)/label_sync/labels.md.tmpl \
    68    --docs-output $(pwd)/label_sync/labels.md
    69  ```
    70  
    71  ## Our Deployment
    72  
    73  We run this as a [`Periodic
    74  job`](https://prow.k8s.io?job=ci-test-infra-label-sync) as configured at
    75  [test-infra-trusted.yaml](https://github.com/kubernetes/test-infra/blob/0aa0d7b9cee8832e9eca748952131baaa809351c/config/jobs/kubernetes/test-infra/test-infra-trusted.yaml#L702).
    76  
    77  This job read [`labels.yaml`](./labels.yaml) from a ConfigMap that is updated by
    78  the [prow updateconfig plugin](/prow/plugins/updateconfig).
    79  
    80  To update the `labels.yaml` file, make the desired changes to `labels.yaml` and
    81  run `make update-labels` from root of this repo. Then open a pull request with the resulting
    82  `labels.yaml` and `labels.md` files.