Skip to content

Commit 9c1030f

Browse files
authored
ci: dedup upstream API change notifications by UTC day (#197)
Receiver workflow now folds all repository_dispatch events of type `upstream-api-endpoint-change` arriving on the same UTC day into a single rolling issue titled "Docs review: upstream API changes (YYYY-MM-DD)". Subsequent dispatches that day append a comment instead of opening a duplicate. The previous logic opened one fresh issue per dispatch. Between Feb 18 and Mar 19, 2026 the legacy Mlaz-code/sharp-api dispatcher fired 185 times (peak 30/day on Mar 6). None were ever triaged. Bulk-close of those issues is happening alongside this rewire; the new dispatcher lives in Mlaz-code/sharp-api-go (notify-docs.yml, separate PR).
1 parent 49a8392 commit 9c1030f

1 file changed

Lines changed: 65 additions & 31 deletions

File tree

Lines changed: 65 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
name: Handle Upstream API Endpoint Change
22

3+
# Receives `repository_dispatch` events from upstream repos (sharp-api-go)
4+
# when handler files change. Dedups to ONE rolling open issue per UTC day —
5+
# subsequent dispatches the same day append a comment instead of opening a
6+
# new issue. This bounds noise at ≤1 new issue/day even at firehose rates.
7+
#
8+
# Earlier version (pre-2026-05) opened a fresh issue per dispatch, which
9+
# produced 185 unread tickets between Feb 18 and Mar 19, 2026.
10+
311
on:
412
repository_dispatch:
513
types: [upstream-api-endpoint-change]
@@ -9,49 +17,75 @@ permissions:
917
contents: read
1018

1119
jobs:
12-
create-review-issue:
20+
upsert-review-issue:
1321
runs-on: self-hosted
1422
timeout-minutes: 5
1523

1624
steps:
17-
- name: Create tracking issue
25+
- name: Upsert daily docs-review issue
1826
env:
1927
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28+
REPO: ${{ github.repository }}
2029
SOURCE: ${{ github.event.client_payload.source_repo }}
2130
CHANGED: ${{ github.event.client_payload.changed_files }}
2231
COMMIT: ${{ github.event.client_payload.commit }}
2332
run: |
24-
BODY="## Upstream API Endpoint Change
25-
26-
**Source repo**: ${SOURCE}
27-
**Commit**: ${COMMIT}
28-
**Changed files**: ${CHANGED}
29-
30-
### Review Checklist
31-
32-
- [ ] Check if API reference docs need updating for changed endpoints
33-
- [ ] Verify request/response examples still match actual API behavior
34-
- [ ] Update any new query parameters or headers
35-
- [ ] Add documentation for any new endpoints
36-
- [ ] Update SDK examples if affected
37-
- [ ] Test code examples against live API
38-
39-
### Context
33+
set -euo pipefail
4034
41-
This issue was auto-created by a \`repository_dispatch\` event from **${SOURCE}**.
42-
API route handlers were modified, which may require documentation updates.
35+
TODAY=$(date -u +%Y-%m-%d)
36+
TITLE="Docs review: upstream API changes (${TODAY})"
37+
SHORT="${COMMIT:0:7}"
38+
# One bullet per dispatched commit — used both as the entry that
39+
# seeds a fresh daily issue's body, and as the comment appended to
40+
# an existing one.
41+
# Source repos all live under the Mlaz-code org (api-adapters,
42+
# sharp-api-go, sharpapi-site, docs.sharpapi.io). SDK repos under
43+
# Sharp-API don't dispatch to docs, so hardcoding Mlaz-code is safe.
44+
ENTRY="- [\`${SHORT}\`](${{ github.server_url }}/Mlaz-code/${SOURCE}/commit/${COMMIT}) — **${SOURCE}** — \`${CHANGED}\`"
4345
44-
If no action is needed, close this issue with a comment explaining why."
46+
EXISTING_NUM=$(gh issue list \
47+
--repo "$REPO" \
48+
--state open \
49+
--label upstream \
50+
--limit 50 \
51+
--json number,title \
52+
| jq -r --arg t "$TITLE" '.[] | select(.title == $t) | .number' \
53+
| head -1)
4554
46-
gh issue create \
47-
--repo "${{ github.repository }}" \
48-
--title "Upstream API endpoint change from ${SOURCE}" \
49-
--label "upstream,docs-update" \
50-
--body "$BODY" || echo "::warning::Issue creation failed"
55+
if [ -n "$EXISTING_NUM" ]; then
56+
gh issue comment "$EXISTING_NUM" --repo "$REPO" --body "$ENTRY"
57+
echo "Appended ${SHORT} to existing issue #${EXISTING_NUM}"
58+
echo "## Upstream notification: appended to #${EXISTING_NUM}" >> "$GITHUB_STEP_SUMMARY"
59+
else
60+
BODY_FILE=$(mktemp)
61+
{
62+
printf '## Upstream API change(s) on %s\n\n' "$TODAY"
63+
printf '%s\n\n' "$ENTRY"
64+
printf '### Review checklist\n\n'
65+
printf -- '- [ ] Update API reference for changed endpoints\n'
66+
printf -- '- [ ] Verify request/response examples still match actual API behavior\n'
67+
printf -- '- [ ] Update query params, headers, or response fields if changed\n'
68+
printf -- '- [ ] Add docs for any new endpoints\n'
69+
printf -- '- [ ] Update SDK examples (`sharpapi-python` / `sharpapi-ts`) if affected\n\n'
70+
printf '### Context\n\n'
71+
printf 'Auto-created by `repository_dispatch` from upstream repos when handler files change. Subsequent dispatches today append comments to this issue. Close it once today'\''s docs review is done.\n'
72+
} > "$BODY_FILE"
73+
NEW_NUM=$(gh issue create \
74+
--repo "$REPO" \
75+
--title "$TITLE" \
76+
--label "upstream,docs-update" \
77+
--body-file "$BODY_FILE" \
78+
| sed -nE 's|.*/issues/([0-9]+).*|\1|p')
79+
rm -f "$BODY_FILE"
80+
echo "Opened new issue #${NEW_NUM} for ${TODAY}"
81+
echo "## Upstream notification: opened #${NEW_NUM}" >> "$GITHUB_STEP_SUMMARY"
82+
fi
5183
52-
- name: Log to summary
84+
- name: Log payload to summary
85+
if: always()
5386
run: |
54-
echo "## Upstream Notification Received" >> $GITHUB_STEP_SUMMARY
55-
echo "**Source**: ${{ github.event.client_payload.source_repo }}" >> $GITHUB_STEP_SUMMARY
56-
echo "**Changed files**: ${{ github.event.client_payload.changed_files }}" >> $GITHUB_STEP_SUMMARY
57-
echo "**Commit**: ${{ github.event.client_payload.commit }}" >> $GITHUB_STEP_SUMMARY
87+
{
88+
echo "**Source**: ${{ github.event.client_payload.source_repo }}"
89+
echo "**Commit**: ${{ github.event.client_payload.commit }}"
90+
echo "**Changed**: ${{ github.event.client_payload.changed_files }}"
91+
} >> "$GITHUB_STEP_SUMMARY"

0 commit comments

Comments
 (0)