Skip to content

Notify #documentation reviewers when autogen-docs PRs are ready#978

Open
claude[bot] wants to merge 4 commits into
mainfrom
add-autogen-docs-slack-notify
Open

Notify #documentation reviewers when autogen-docs PRs are ready#978
claude[bot] wants to merge 4 commits into
mainfrom
add-autogen-docs-slack-notify

Conversation

@claude

@claude claude Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Requested by Daniel Barr · Slack thread

Before / After

Before: When an autogen-docs PR (the Renovate-authored upstream version-bump docs PRs) goes ready-for-review, docs reviewers rely on the limited GitHub-native Slack integration / generic PR notifications. Those are noisy, don't summarize what actually changed, and don't tell a given reviewer what they specifically need to look at.

After: When an autogen-docs PR is flipped to ready-for-review, the #documentation channel gets a single tailored summary: a one-line headline of which upstream project/version the docs update is for (linked to the PR), a 2-4 bullet recap reusing the PR's "At a glance" summary, and a Reviewers section that tags each requested reviewer with the specific thing they should check.

How it works

  • Trigger: pull_request with types: [ready_for_review]. The existing Upstream Release Docs workflow flips these PRs draft -> ready via gh pr ready at the end of its run, which emits exactly this event.
  • Label guard: the job only runs when the PR carries the autogen-docs label (applied by Renovate) and is authored by renovate[bot], so human PRs and other bots' PRs are ignored.
  • claude-code-action (prompt/automation mode): a single anthropics/claude-code-action step (same pinned SHA, claude-opus-4-7, allowed_bots: 'renovate') runs a prompt that uses gh pr view to read the PR (title, body, requested reviewers, files), reuses the marker-delimited ... "At a glance" summary, resolves each requested reviewer's GitHub handle to a Slack id via the Slack profile "GitHub" field (falling back to a plain @handle when there's no match), and composes one message.
  • Slack delivery: the message is posted with curl to the Slack Web API chat.postMessage. The step checks the response ok field and fails (non-zero exit) if Slack returns an error.

Before this can run

  • New secret SLACK_BOT_TOKEN (a Slack bot token, xoxb-...) must be added to the repo. Required scopes:
    • chat:write — post the message
    • users:read — list users to map GitHub handle -> Slack id
    • users.profile:read — read the custom "GitHub" profile field
    • users:read.email — only if email-based matching is used as a fallback
  • Slack profile GitHub handles: reviewer @-tagging depends on each reviewer's GitHub handle being present in their Slack profile (the Okta-pushed "GitHub" custom field). When a handle can't be matched, the message falls back to the plain GitHub @handle as text rather than guessing a Slack id.
  • Channel membership: the Slack bot must be invited to the #documentation channel (id C06SZA9HBHU, set directly as an env var since channel ids are not secret), or chat.postMessage fails with not_in_channel.

🤖 Generated with Claude Code

When a Renovate-authored autogen-docs PR is flipped to ready-for-review,
run claude-code-action to post a tailored reviewer summary into the
#documentation Slack channel, tagging each requested reviewer with what
to check. Reuses the marker-delimited 'At a glance' summary from the
Upstream Release Docs workflow and resolves GitHub handles to Slack ids
via Slack profile fields, falling back to plain @Handles.
@vercel

vercel Bot commented Jun 25, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs-website Ready Ready Preview, Comment Jun 26, 2026 6:29pm

Request Review

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a dedicated GitHub Actions workflow to post a tailored Slack notification to #documentation when Renovate-authored autogen-docs PRs transition from draft to ready-for-review, aiming to reduce noise and give reviewers targeted guidance.

Changes:

  • Introduces a new workflow triggered by pull_request: ready_for_review gated to autogen-docs + renovate[bot].
  • Runs anthropics/claude-code-action to read PR metadata (including the marker-delimited “At a glance” summary) and compose a single Slack message.
  • Posts the message to Slack via chat.postMessage, attempting to map GitHub reviewer handles to Slack user IDs via users.list / profile fields.

Comment thread .github/workflows/autogen-docs-notify.yml
Comment thread .github/workflows/autogen-docs-notify.yml Outdated
Address two Copilot security review comments:

- Switch trigger from pull_request to pull_request_target so the
  workflow definition is read from the trusted base branch, not the
  PR head. The label + renovate[bot] author guard is unchanged. Safe
  because the workflow never checks out or executes PR-supplied code.

- Split the single Claude step (which held SLACK_BOT_TOKEN and could
  run arbitrary curl) into two steps. Claude now composes message
  content only, with tools limited to Bash(gh:*) and Write and no
  Slack token in scope. A new deterministic stdlib-only Python poster
  (.github/scripts/post_autogen_docs_slack.py) is the only place the
  Slack token lives and only ever contacts slack.com; it resolves
  reviewer GitHub handles to Slack ids and posts the message.
@danbarr danbarr marked this pull request as ready for review June 26, 2026 17:52
Slack's users.list does not reliably return custom profile fields, so
the GitHub-handle field was usually absent and every reviewer fell back
to a plain @handle. Discover the field id once via team.profile.get,
enumerate member ids via users.list, and read each user's custom field
value via users.profile.get (with 429 Retry-After handling and per-user
error skipping). Ambiguous handles are dropped so callers fall back to
@handle text.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants