mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-01-10 01:19:50 +00:00
ci(deps): add GH_TOKEN to GitHub API requests (#13502)
This commit is contained in:
15
.github/workflows/dependencies/updater.py
vendored
15
.github/workflows/dependencies/updater.py
vendored
@@ -18,6 +18,13 @@ TMP_DIR = os.path.join(os.environ.get("TMP_DIR", "/tmp"), "ohmyzsh")
|
|||||||
DEPS_YAML_FILE = ".github/dependencies.yml"
|
DEPS_YAML_FILE = ".github/dependencies.yml"
|
||||||
# Dry run flag
|
# Dry run flag
|
||||||
DRY_RUN = os.environ.get("DRY_RUN", "0") == "1"
|
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
|
# utils for tag comparison
|
||||||
BASEVERSION = re.compile(
|
BASEVERSION = re.compile(
|
||||||
@@ -453,7 +460,7 @@ class GitHub:
|
|||||||
url = f"https://api.github.com/repos/{repo}/git/refs/tags"
|
url = f"https://api.github.com/repos/{repo}/git/refs/tags"
|
||||||
|
|
||||||
# Send a GET request to the GitHub API
|
# Send a GET request to the GitHub API
|
||||||
response = requests.get(url)
|
response = requests.get(url, headers=HEADERS)
|
||||||
current_version = coerce(current_tag)
|
current_version = coerce(current_tag)
|
||||||
if current_version is None:
|
if current_version is None:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
@@ -513,7 +520,7 @@ class GitHub:
|
|||||||
url = f"https://api.github.com/repos/{repo}/compare/{version}...{branch}"
|
url = f"https://api.github.com/repos/{repo}/compare/{version}...{branch}"
|
||||||
|
|
||||||
# Send a GET request to the GitHub API
|
# Send a GET request to the GitHub API
|
||||||
response = requests.get(url)
|
response = requests.get(url, headers=HEADERS)
|
||||||
|
|
||||||
# If the request was successful
|
# If the request was successful
|
||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
@@ -595,14 +602,14 @@ def main():
|
|||||||
|
|
||||||
# Cache YAML version
|
# Cache YAML version
|
||||||
DependencyStore.set(data)
|
DependencyStore.set(data)
|
||||||
|
|
||||||
dependencies = data["dependencies"]
|
dependencies = data["dependencies"]
|
||||||
if len(sys.argv) > 1:
|
if len(sys.argv) > 1:
|
||||||
# argv is list of dependencies to run, default is all of them
|
# argv is list of dependencies to run, default is all of them
|
||||||
dependency_list = sys.argv[1:]
|
dependency_list = sys.argv[1:]
|
||||||
else:
|
else:
|
||||||
dependency_list = dependencies.keys()
|
dependency_list = dependencies.keys()
|
||||||
|
|
||||||
for path in dependency_list:
|
for path in dependency_list:
|
||||||
dependency = Dependency(path, dependencies[path])
|
dependency = Dependency(path, dependencies[path])
|
||||||
dependency.update_or_notify()
|
dependency.update_or_notify()
|
||||||
|
|||||||
Reference in New Issue
Block a user