-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
551 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -255,3 +255,5 @@ dmypy.json | |
|
||
# Cython debug symbols | ||
cython_debug/ | ||
|
||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import json | ||
import sys | ||
import requests | ||
|
||
# Constants | ||
REPO_OWNER = "brainhackorg" | ||
REPO_NAME = "global2024" | ||
API_URL = f"https://api.github.com/repos/{REPO_OWNER}/{REPO_NAME}/labels" | ||
TOKEN = sys.argv[1] | ||
HEADERS = { | ||
"Authorization": f"token {TOKEN}", | ||
"Accept": "application/vnd.github.v3+json", | ||
} | ||
|
||
# Read labels from JSON file | ||
with open("labels.json", "r") as file: | ||
labels = json.load(file) | ||
|
||
|
||
# Function to create or update a label | ||
def create_or_update_label(label): | ||
response = requests.post(API_URL, headers=HEADERS, json=label) | ||
if response.status_code == 201: | ||
print(f"Created label: {label['name']}") | ||
elif response.status_code == 422: | ||
# Label already exists, update it | ||
update_url = f"{API_URL}/{label['name']}" | ||
response = requests.patch(update_url, headers=HEADERS, json=label) | ||
if response.status_code == 200: | ||
print(f"Updated label: {label['name']}") | ||
else: | ||
print( | ||
f"Failed to update label: {label['name']}, {response.status_code}, {response.text}" | ||
) | ||
else: | ||
print( | ||
f"Failed to create label: {label['name']}, {response.status_code}, {response.text}" | ||
) | ||
|
||
|
||
# Upload labels to the repository | ||
for label in labels: | ||
create_or_update_label(label) |
Oops, something went wrong.