Skip to content

Commit

Permalink
Auto labels creatio [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
lmazuel committed Jul 24, 2018
1 parent 9230842 commit eed1e22
Show file tree
Hide file tree
Showing 2 changed files with 131 additions and 0 deletions.
92 changes: 92 additions & 0 deletions scripts/github_labels.txt
Original file line number Diff line number Diff line change
@@ -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
39 changes: 39 additions & 0 deletions scripts/push_labels.py
Original file line number Diff line number Diff line change
@@ -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])

0 comments on commit eed1e22

Please sign in to comment.