Update or migrate github labels on repos in a github org based on a YAML file
A typical labels.yaml file looks like:
---
labels:
- color: 00ff00
name: lgtm
- color: ff0000
name: priority/P0
previously:
- color: 0000ff
name: P0
- name: dead-label
color: cccccc
deleteAfter: 2017-01-01T13:00:00Z
This will ensure that:
- there is a green
lgtm
label - there is a red
priority/P0
label, and previous labels should be migrated to it:- if a
P0
label exists:- if
priority/P0
does not, modify the existingP0
label - if
priority/P0
exists,P0
labels will be deleted,priority/P0
labels will be added
- if
- if a
- if there is a
dead-label
label, it will be deleted after 2017-01-01T13:00:00Z
# test
bazel test //label_sync/...
# add or migrate labels on all repos in the kubernetes org
bazel run //label_sync -- \
--config $(pwd)/labels.yaml \
--token /path/to/github_oauth_token \
--orgs kubernetes
# actually you need to pass the --confirm flag too, it will
# run in dry-run mode by default so you avoid doing something
# too hastily, hence why this copy-pasta isn't including it
# add or migrate labels on all repos except helm in the kubernetes org
bazel run //label_sync -- \
--config $(pwd)/labels.yaml \
--token /path/to/github_oauth_token \
--orgs kubernetes \
--skip kubernetes/helm
# see above
# add or migrate labels on the community and steering repos in the kubernetes org
bazel run //label_sync -- \
--config $(pwd)/labels.yaml \
--token /path/to/github_oauth_token \
--orgs kubernetes \
--only kubernetes/community,kubernetes/steering
# see above
# generate docs based on labels.yaml
bazel run //label_sync -- \
--action docs \
--config $(pwd)/labels.yaml \
--docs-template $(pwd)/labels.md.tmpl \
--docs-output $(pwd)/labels.md
We run this as a CronJob
on a kubernetes cluster managed by test-infra oncall, and can also schedule it as a Job
for one-shot usage.
These pods read labels.yaml
from a ConfigMap that is updated by the prow updateconfig plugin.
To update the labels.yaml
file, simply open a pull request against it.