1
0
mirror of https://github.com/robbyrussell/oh-my-zsh.git synced 2026-01-07 11:04:46 +01:00

ci(deps): add GH_TOKEN to GitHub API requests (#13502)

This commit is contained in:
Carlo Sala
2026-01-05 12:36:14 +01:00
committed by GitHub
parent 72625e2f2f
commit 28d4ab6e98

View File

@@ -18,6 +18,13 @@ TMP_DIR = os.path.join(os.environ.get("TMP_DIR", "/tmp"), "ohmyzsh")
DEPS_YAML_FILE = ".github/dependencies.yml"
# Dry run flag
DRY_RUN = os.environ.get("DRY_RUN", "0") == "1"
# GitHub Token is needed to avoid rate limiting
GH_TOKEN = os.environ.get("GH_TOKEN")
HEADERS = {
"Accept": "application/vnd.github+json",
}
if GH_TOKEN:
HEADERS["Authorization"] = f"Bearer {GH_TOKEN}"
# utils for tag comparison
BASEVERSION = re.compile(
@@ -453,7 +460,7 @@ class GitHub:
url = f"https://api.github.com/repos/{repo}/git/refs/tags"
# Send a GET request to the GitHub API
response = requests.get(url)
response = requests.get(url, headers=HEADERS)
current_version = coerce(current_tag)
if current_version is None:
raise ValueError(
@@ -513,7 +520,7 @@ class GitHub:
url = f"https://api.github.com/repos/{repo}/compare/{version}...{branch}"
# Send a GET request to the GitHub API
response = requests.get(url)
response = requests.get(url, headers=HEADERS)
# If the request was successful
if response.status_code == 200:
@@ -595,14 +602,14 @@ def main():
# Cache YAML version
DependencyStore.set(data)
dependencies = data["dependencies"]
if len(sys.argv) > 1:
# argv is list of dependencies to run, default is all of them
dependency_list = sys.argv[1:]
else:
dependency_list = dependencies.keys()
for path in dependency_list:
dependency = Dependency(path, dependencies[path])
dependency.update_or_notify()