scripts/github_utils.py
scripts/github_utils.pyBrowse 8 files
157 tokens
659 bytes
Token encoding: o200k_base
Snapshot 18d7ace
← Back to SKILL.md
1#!/usr/bin/env python32"""Shared GitHub helpers for skill install scripts."""3 4from __future__ import annotations5 6import os7import urllib.request8 9 10def github_request(url: str, user_agent: str) -> bytes:11 headers = {"User-Agent": user_agent}12 token = os.environ.get("GITHUB_TOKEN") or os.environ.get("GH_TOKEN")13 if token:14 headers["Authorization"] = f"token {token}"15 req = urllib.request.Request(url, headers=headers)16 with urllib.request.urlopen(req) as resp:17 return resp.read()18 19 20def github_api_contents_url(repo: str, path: str, ref: str) -> str:21 return f"https://api.github.com/repos/{repo}/contents/{path}?ref={ref}"22 