Skip to content

Commit 74c51bf

Browse files
committed
Use Copilot API for release note summaries
Update the release-notes workflow to call Copilot with a dedicated `COPILOT_API_KEY` instead of the previous GitHub Models endpoint. The request now uses a chat payload with system and user messages and sends it via `requests.post`, while keeping the existing error fallback that prints raw commits when generation fails.
1 parent 9b6cb6f commit 74c51bf

1 file changed

Lines changed: 23 additions & 18 deletions

File tree

.github/workflows/generate-release-notes.yml

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ jobs:
7373
prev_tag = os.environ['PREV_TAG_DATA']
7474
commits = os.environ['COMMITS_DATA']
7575
token = os.environ['GH_TOKEN']
76+
copilot_key = os.getenv("COPILOT_API_KEY")
7677
7778
prompt = (
7879
f"Generate concise release notes for version {current_tag}.\n\n"
@@ -82,28 +83,32 @@ jobs:
8283
"and Other Changes(excludes Full Changelog).\n\n"
8384
"Be concise and clear."
8485
)
86+
87+
copilot_url = "https://githubcopilot.com"
88+
copilot_headers = {
89+
"Authorization": f"Bearer {copilot_key}",
90+
"Content-Type": "application/json"
91+
}
8592
86-
payload = json.dumps({
87-
"model": "openai/gpt-4o",
88-
"messages": [{"role": "user", "content": prompt}]
89-
}).encode()
90-
91-
req = urllib.request.Request(
92-
"https://models.github.ai/inference/chat/completions",
93-
data=payload,
94-
headers={
95-
"Content-Type": "application/json",
96-
"Authorization": f"Bearer {token}"
93+
payload = {
94+
"model": "copilot-gpt-4",
95+
"messages": [
96+
{
97+
"role": "system",
98+
"content": "You are an expert software engineer generating a clear, technical commit summary."
99+
},
100+
{
101+
"role": "user",
102+
"content": prompt
97103
}
98-
)
104+
]
105+
}
99106
100107
try:
101-
with urllib.request.urlopen(req) as resp:
102-
data = json.loads(resp.read())
103-
if "choices" in data and len(data["choices"]) > 0:
104-
print(data["choices"][0]["message"]["content"])
105-
else:
106-
raise ValueError("Invalid response structure from Copilot API")
108+
response = requests.post(copilot_url, json=payload, headers=copilot_headers)
109+
response.raise_for_status()
110+
copilot_summary = response.json()['choices']['message']['content']
111+
print(copilot_summary)
107112
except Exception as e:
108113
print(f"Failed to generate summary via Copilot: {e}", file=sys.stderr)
109114
print(f"_Release notes generation failed. Raw commits since {prev_tag}:_\n\n```\n{commits}\n```")

0 commit comments

Comments
 (0)