Add plugin update and install reporting
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import os
|
||||
from typing import Any
|
||||
from urllib.request import Request, urlopen
|
||||
|
||||
|
||||
def fetch_releases(repo: str) -> list[dict[str, Any]]:
|
||||
token = os.environ.get("GITHUB_TOKEN")
|
||||
headers = {
|
||||
"Accept": "application/vnd.github+json",
|
||||
"User-Agent": "plugin-helper",
|
||||
}
|
||||
if token:
|
||||
headers["Authorization"] = f"Bearer {token}"
|
||||
request = Request(f"https://api.github.com/repos/{repo}/releases", headers=headers)
|
||||
with urlopen(request, timeout=20) as response:
|
||||
data = json.loads(response.read().decode("utf-8"))
|
||||
if not isinstance(data, list):
|
||||
raise ValueError(f"unexpected GitHub releases response for {repo}")
|
||||
return data
|
||||
Reference in New Issue
Block a user