File indexing completed on 2025-01-18 09:10:44
0001
0002
0003 import os
0004 import urllib.request
0005 import json
0006 import sys
0007
0008 GITHUB_TOKEN = os.environ["GH_TOKEN"]
0009 GITHUB_REPO = os.environ["GH_REPO"]
0010
0011 with urllib.request.urlopen(
0012 urllib.request.Request(
0013 f"https://api.github.com/repos/{GITHUB_REPO}/milestones?state=open",
0014 headers={"Authorization": f"Bearer {GITHUB_TOKEN}"},
0015 )
0016 ) as response:
0017 milestones = json.loads(response.read())
0018
0019
0020 sys.stderr.write(f"Found {len(milestones)} milestones\n")
0021 for m in milestones:
0022 sys.stderr.write(f"- {m['title']}\n")
0023
0024
0025 titles = [m["title"] for m in milestones if m["title"] != "next"]
0026 titles.sort()
0027
0028 if len(titles) == 0:
0029 raise RuntimeError("No eligible milestone found")
0030
0031 print(titles[0])