Skip to content

Commit 7c4de2d

Browse files
committed
Migrate AI commit message generation to Copilot CLI
1 parent bc55a96 commit 7c4de2d

3 files changed

Lines changed: 20 additions & 30 deletions

File tree

‎.github/prompts/commit-message.prompt.yml‎

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ messages:
33
content: |-
44
You write concise git commit messages describing automated updates to a Slack Web
55
API reference JSON repository (methods, groups and events scraped from Slack's docs).
6-
Given a diffstat and a diff, respond with:
6+
Given a diffstat and a diff, respond with ONLY a single JSON object (no markdown code
7+
fences, no other text) with exactly these two keys:
8+
{"title": "...", "summary": "..."}
79
- title: a single line, imperative mood, at most 72 characters, no trailing period,
810
describing the most significant change (e.g. "Add chat.appendStream and
911
chat.stopStream methods").
1012
- summary: 1-5 short bullet points (each starting with "- "), each describing one
1113
notable change: new/removed/renamed methods or events, added/removed arguments,
12-
changed error codes, etc.
14+
changed error codes, etc. Use "" if nothing notable.
1315
If the diff is routine or has no notable API surface changes, keep the title generic
1416
(e.g. "Minor documentation updates") and the summary brief or empty.
1517
- role: user
@@ -19,25 +21,3 @@ messages:
1921
2022
Diff (may be truncated):
2123
{{diff}}
22-
model: openai/gpt-4o-mini
23-
responseFormat: json_schema
24-
jsonSchema: |-
25-
{
26-
"name": "commit_message",
27-
"strict": true,
28-
"schema": {
29-
"type": "object",
30-
"properties": {
31-
"title": {
32-
"type": "string",
33-
"description": "Single-line, imperative-mood commit title, max 72 characters, no trailing period"
34-
},
35-
"summary": {
36-
"type": "string",
37-
"description": "1-5 short bullet points, each starting with '- ', or empty string if nothing notable"
38-
}
39-
},
40-
"additionalProperties": false,
41-
"required": ["title", "summary"]
42-
}
43-
}

‎.github/workflows/update.yml‎

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ on:
77

88
permissions:
99
contents: write
10-
models: read
1110

1211
jobs:
1312
update:
@@ -39,25 +38,35 @@ jobs:
3938
- name: Prepare diff for AI summary
4039
if: steps.changes.outputs.changed == 'true'
4140
run: |
42-
git diff --stat > /tmp/diff_stat.txt
43-
git diff | head -c 20000 > /tmp/diff.txt
41+
git diff --stat | sed 's/^/ /' > /tmp/diff_stat.txt
42+
git diff | head -c 20000 | sed 's/^/ /' > /tmp/diff.txt
43+
- name: Set up Node
44+
if: steps.changes.outputs.changed == 'true'
45+
uses: actions/setup-node@v6
46+
- name: Install Copilot CLI
47+
if: steps.changes.outputs.changed == 'true'
48+
run: npm install -g @github/copilot
4449
- name: Generate commit message with AI
4550
if: steps.changes.outputs.changed == 'true'
4651
id: ai
47-
uses: actions/ai-inference@v1
52+
uses: actions/ai-inference@v3
4853
with:
4954
prompt-file: ./.github/prompts/commit-message.prompt.yml
55+
model: ''
5056
file_input: |
5157
diff_stat: /tmp/diff_stat.txt
5258
diff: /tmp/diff.txt
59+
env:
60+
COPILOT_GITHUB_TOKEN: ${{ secrets.COPILOT_PAT }}
5361
- name: Build commit message
5462
id: message
5563
run: |
5664
title=""
5765
summary=""
5866
if [ "${{ steps.changes.outputs.changed }}" = "true" ]; then
59-
title="$(jq -r '.title // empty' "${{ steps.ai.outputs.response-file }}" 2>/dev/null)"
60-
summary="$(jq -r '.summary // empty' "${{ steps.ai.outputs.response-file }}" 2>/dev/null)"
67+
response="$(grep -v '^```' "${{ steps.ai.outputs.response-file }}" 2>/dev/null)"
68+
title="$(echo "$response" | jq -r '.title // empty' 2>/dev/null)"
69+
summary="$(echo "$response" | jq -r '.summary // empty' 2>/dev/null)"
6170
fi
6271
if [ -z "$title" ]; then
6372
title="Updated from Slack docs, ${CURRENT_DATE}"

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Changelog
44
Some notable infrastructure contributions below. See [commits](commits/master) for Slack API updates.
55

66
* Your contribution here.
7+
* [#89](https://github.com/slack-ruby/slack-api-ref/pull/89): Migrate AI commit message generation to Copilot CLI after GitHub Models retirement - [@dblock](https://github.com/dblock).
78
* [#87](https://github.com/slack-ruby/slack-api-ref/pull/87): Generate AI commit summaries for automated API updates - [@dblock](https://github.com/dblock).
89
* [#64](https://github.com/slack-ruby/slack-api-ref/pull/64): Add `arg_groups` for groups of arguments whose requirement is interdependent - [@jmanian](https://github.com/jmanian).
910
* [#64](https://github.com/slack-ruby/slack-api-ref/pull/64): Add `"format": "json"` attribute for arguments that need to be JSON strings - [@jmanian](https://github.com/jmanian).

0 commit comments

Comments
 (0)