From eed1e228847d90d97ca55ded98e10a915b391b61 Mon Sep 17 00:00:00 2001 From: Laurent Mazuel Date: Tue, 24 Jul 2018 11:27:02 -0700 Subject: [PATCH] Auto labels creatio [skip ci] --- scripts/github_labels.txt | 92 +++++++++++++++++++++++++++++++++++++++ scripts/push_labels.py | 39 +++++++++++++++++ 2 files changed, 131 insertions(+) create mode 100644 scripts/github_labels.txt create mode 100644 scripts/push_labels.py diff --git a/scripts/github_labels.txt b/scripts/github_labels.txt new file mode 100644 index 000000000000..6065f384ae00 --- /dev/null +++ b/scripts/github_labels.txt @@ -0,0 +1,92 @@ +AAD +ACS +AKS +ARM +Advisor +Analysis Services +API Management +Application Insights +App Services +Authorization +Automation +Azure Stack +Azure Cloud Shell +Batch +BatchAI +Billing +CDN +Cognitive Services +Commerce +Compute +Compute - Extensions +Compute - Images +Compute - Managed Disks +Compute - VM +Compute - VMSS +Consumption +Container Instance +Container Registry +CosmosDB +Customer Insights +Data Catalog +Data Factory +Data Lake +Data Lake Analytics +Data Lake Store +Data Migration +Devtestlab +Event Grid +Event Hub +Graph +HDInsight +Import Export +Intune +Insights +IotHub +KeyVault +Logic App +Machine Learning +Machine Learning Compute +Machine Learning Experimentation +Marketplace Ordering +Media Services +Migrate +Mobile Engagement +Monitor +MySQL +Network +Network - Application Gateway +Network - Express Routes +Network - Gateways +Network - Load Balancer +Network - Watcher +Network - DNS +Network - Traffic Manager +Notification Hubs +Operational Insights +Operations Management +Policy Insights +PostgreSQL +PowerBI +Recovery Services +Recovery Services Backup +Recovery Services Site-Recovery +Redis Cache +Relay +Reservations +Resource Authorization +Resource Manager +Resource Health +Search +Security +Scheduler +Server Management +Service Bus +Service Fabric +Service Map +SQL +Storage +Storsimple +Stream Analytics +TimeseriesInsights +Visual Studio diff --git a/scripts/push_labels.py b/scripts/push_labels.py new file mode 100644 index 000000000000..bd437b50a7ce --- /dev/null +++ b/scripts/push_labels.py @@ -0,0 +1,39 @@ +import os +import sys + +from github import Github, GithubException + +LABEL_COLOUR = "e99695" + + +def get_repo(repo_name): + con = Github(os.environ["GH_TOKEN"]) + repo = con.get_repo(repo_name) + repo.name # Force checking if repo exists, otherwise "get_repo" does nothing + return repo + + +def create_label(repo, label): + print(f"Adding label {label}") + try: + repo.create_label(label, LABEL_COLOUR) + print(f"-> Created label {label}") + except GithubException as err: + err_code = err.data['errors'][0].get('code', '') + if err.status == 422 and err_code == "already_exists": + print(f"-> Label {label} already exists") + return + raise + +def do(repo_name, label_filepath): + print(f"Getting repo {repo_name}") + repo = get_repo(repo_name) + + print("Adding labels to repo") + with open(label_filepath, "r") as fd: + for label in fd.read().splitlines(): + create_label(repo, label) + + +if __name__ == "__main__": + do(sys.argv[1], sys.argv[2]) \ No newline at end of file