Skip to content

Commit bc55a96

Browse files
authored
Merge pull request #87 from dblock/ai-generated-update-summary
Generate AI commit summaries for automated API updates
2 parents 07ae43b + 6a27bb7 commit bc55a96

5 files changed

Lines changed: 93 additions & 3 deletions

File tree

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
messages:
2+
- role: system
3+
content: |-
4+
You write concise git commit messages describing automated updates to a Slack Web
5+
API reference JSON repository (methods, groups and events scraped from Slack's docs).
6+
Given a diffstat and a diff, respond with:
7+
- title: a single line, imperative mood, at most 72 characters, no trailing period,
8+
describing the most significant change (e.g. "Add chat.appendStream and
9+
chat.stopStream methods").
10+
- summary: 1-5 short bullet points (each starting with "- "), each describing one
11+
notable change: new/removed/renamed methods or events, added/removed arguments,
12+
changed error codes, etc.
13+
If the diff is routine or has no notable API surface changes, keep the title generic
14+
(e.g. "Minor documentation updates") and the summary brief or empty.
15+
- role: user
16+
content: |-
17+
Diffstat:
18+
{{diff_stat}}
19+
20+
Diff (may be truncated):
21+
{{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: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ on:
55
schedule:
66
- cron: "15 22 * * *"
77

8+
permissions:
9+
contents: write
10+
models: read
11+
812
jobs:
913
update:
1014
runs-on: ubuntu-latest
@@ -24,9 +28,51 @@ jobs:
2428
run: bundle exec rake api:validate
2529
- name: Get current date
2630
run: echo "CURRENT_DATE=$(date +%Y/%m/%d)" >> $GITHUB_ENV
31+
- name: Check for changes
32+
id: changes
33+
run: |
34+
if git diff --quiet; then
35+
echo "changed=false" >> "$GITHUB_OUTPUT"
36+
else
37+
echo "changed=true" >> "$GITHUB_OUTPUT"
38+
fi
39+
- name: Prepare diff for AI summary
40+
if: steps.changes.outputs.changed == 'true'
41+
run: |
42+
git diff --stat > /tmp/diff_stat.txt
43+
git diff | head -c 20000 > /tmp/diff.txt
44+
- name: Generate commit message with AI
45+
if: steps.changes.outputs.changed == 'true'
46+
id: ai
47+
uses: actions/ai-inference@v1
48+
with:
49+
prompt-file: ./.github/prompts/commit-message.prompt.yml
50+
file_input: |
51+
diff_stat: /tmp/diff_stat.txt
52+
diff: /tmp/diff.txt
53+
- name: Build commit message
54+
id: message
55+
run: |
56+
title=""
57+
summary=""
58+
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)"
61+
fi
62+
if [ -z "$title" ]; then
63+
title="Updated from Slack docs, ${CURRENT_DATE}"
64+
summary=""
65+
fi
66+
{
67+
echo 'message<<COMMIT_MESSAGE_EOF'
68+
echo "$title"
69+
echo ""
70+
echo "$summary"
71+
echo 'COMMIT_MESSAGE_EOF'
72+
} >> "$GITHUB_OUTPUT"
2773
- name: Commit changes
2874
uses: EndBug/add-and-commit@v9
2975
with:
3076
author_name: Slack API Ref Buildbot
3177
author_email: buildbot@slack-api-ref.com
32-
message: "Updated from Slack docs, ${{ env.CURRENT_DATE }}"
78+
message: ${{ steps.message.outputs.message }}

‎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+
* [#87](https://github.com/slack-ruby/slack-api-ref/pull/87): Generate AI commit summaries for automated API updates - [@dblock](https://github.com/dblock).
78
* [#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).
89
* [#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).
910
* [#58](https://github.com/slack-ruby/slack-api-ref/pull/58): Set up Rubocop - [@kstole](https://github.com/kstole).

‎LICENSE.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2015-2017 Daniel Doubrovkine, Artsy and Contributors
3+
Copyright (c) 2015-2026 Daniel Doubrovkine, Artsy and Contributors
44

55
Permission is hereby granted, free of charge, to any person obtaining
66
a copy of this software and associated documentation files (the

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@ This project is not affiliated with the [company that makes Slack](https://slack
3535

3636
### Copyright & License
3737

38-
Copyright (c) 2015-2017, Daniel Doubrovkine and [Contributors](CHANGELOG.md).
38+
Copyright (c) 2015-2026, Daniel Doubrovkine and [Contributors](CHANGELOG.md).
3939

4040
This project is licensed under the [MIT License](LICENSE.md).

0 commit comments

Comments
 (0)